pclose returning -1

Hi all,

In my application i am trying to select some text & then give it to print. for this i am opening a stream using popen & then later closing using pclose.
Now this is working fine in my environment (solaris) but the pclose function is failing at my clients m/c. Even though print is happening (i.e, no problem with the implementation) but still as pclose is failing it will throw an error message.
I have read pclose fails due to some problem with waitpid(). But what is that trouble ?
Also he has captured the truss output ( system calls made by the appln) which are as follows :

29340: time() = 1164271259
29340: time() = 1164271259
29340: llseek(9, 0, SEEK_CUR) = 605
29340: close(9) = 0
29340: time() = 1164271259
29340: unlink("/tmp//45655e9b03dde") = 0
29340: fstat64(1, 0xFFBFA930) = 0
request id is bw-b15rd-185608 (1 file(s))
29340: write(1, " r e q u e s t i d i".., 42) = 42
29340: _exit(0)
29338: waitid(P_PID, 29340, 0xFFBFE5F0, WEXITED|WTRAPPED|WNOWAIT) = 0
29338: getpgid(29340) = 29306
29338: waitid(P_PID, 29340, 0xFFBFE5F0, WEXITED|WTRAPPED) = 0
29338: _exit(0)
29307: Received signal #18, SIGCLD, in waitid() [caught]
29307: siginfo: SIGCLD CLD_EXITED pid=29338 status=0x0000
29307: waitid(P_PID, 29338, 0xFFBFC0B0, WEXITED|WTRAPPED|_WNOCHLD) Err#4 EINTR
29307: sigprocmask(SIG_SETMASK, 0xFFBFBCB4, 0x00000000) = 0
29307: wait() = 29338 [0x0000]
29307: sigprocmask(SIG_SETMASK, 0xFEFEA074, 0xFFBFBA68) = 0
29307: lwp_unpark(1, 1) = 0
29307: setcontext(0xFFBFBA78)
29307: waitid(P_PID, 29338, 0xFFBFC0B0, WEXITED|WTRAPPED|_WNOCHLD) Err#10 ECHILD
29307: uname(0xFFBFB768) = 1
29307: getpid() = 29307 [29306]
29307: write(3, "12\0\0\b\0\0\0 -\0\002 >".., 5420) = 5420
29307: read(3, 0xFFBFBE00, 32) Err#11 EAGAIN
29307: read(3, "02 @ b @13F98DA3\0\0\0 -".., 32) = 32
29307: read(3, 0xFFBFBE00, 32) Err#11 EAGAIN
29307: read(3, "1C : b A\0\0\0 -\0\002 >".., 32) = 32
29307: read(3, "16\0 b b\0C805B3\0C805B3".., 32) = 32

Can some 1 tell me y pclose is returning -1 every time ?

THanks
Nimisha

The ECHILD errno means that waitid failed. It basically means there are no children to wait for - they have all terminated before the call was made.

Thanks , but then what is the dependency of child processes with my application. as i am not explictly creating one and also u knw ne way of correcting this behavior of child process

What shell command(s) does popen execute?