title: How to fseek() on a pipe
body: <p>I am trying to dynamically allocate memory for output of popen but trying to find the length of the file is giving "illegal seek" error. The code is</p>
  
  <pre><code>#include&lt;stdio.h&gt;
  #include&lt;string.h&gt;
  #include&lt;stdlib.h&gt;
  void main()
  {
      char cmd[40] = {0};
      char * c;
      int byteCount = 0;
      FILE * pFp = NULL;
      strncpy(cmd, "ls -l", sizeof(cmd));
      pFp =  popen(cmd, "r");
      if (pFp == NULL)
          printf ("file is null");
      fseek(pFp, 0, SEEK_END);
      byteCount = ftell(pFp);
      perror("seek ");
      fclose(pFp);
  }
  </code></pre>
  
  <p>fgets works fine, are there any constraints in using fseek with popen?
  Thanks in advance.</p>