popen / pclose - Solaris

On Solaris 6, 8, 9:

#include <stdio.h>

main()
{
        FILE \*fp = popen("/bin/ls", "r");
        while (fgetc(fp) != -1)
                ;
        pclose(fp);
        perror("");
}

bash-2.03$ cc test.c
bash-2.03$ ./a.out
Illegal seek
bash-2.03$ 

Whathafakisthat??

Comments:

ok, looks like pclose() does a llseek() internally...

Posted by motor on mars 29, 2007 at 07:25 MD PDT #

Actually, you should only call perror if the pclose actually failed:

http://www.opengroup.org/onlinepubs/009695399/functions/errno.html

"The setting of errno after a successful call to a function is unspecified unless the description of that function specifies that errno shall not be modified."

Posted by Dan Nelson on mars 30, 2007 at 02:55 PD PDT #

Yes, that makes sense...thanks.

Posted by motor on prill 12, 2007 at 02:10 MD PDT #

very interesting

Posted by auction car insurance salvage on qershor 11, 2007 at 05:39 PD PDT #

Post a Comment:
  • HTML Syntax: NOT allowed
About

user13334066

Search

Archives
« prill 2014
DieHënMarMërEnjPreSht
  
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
   
       
Today