Re: popen: how to know the child has exited?
- From: scott@xxxxxxxxxxxxx (Scott Lurndal)
- Date: Thu, 13 Mar 2008 21:07:29 GMT
Bin Chen <binary.chen@xxxxxxxxx> writes:
On Mar 13, 8:51 am, Rex Mottram <rex.mott...@xxxxxxxx> wrote:
Barry Margolin wrote:Oh thank you!
In article <r7idnbqa6MDWJkranZ2dnUVZ_gudn...@xxxxxxxxxxx>,
Rex Mottram <rex.mott...@xxxxxxxx> wrote:
Bin Chen wrote:
Hi,
I am using popen() to run a program, the parameters I passed to
popen() is "w" because the program will read some input from stdin
which I want to write from the parent program.
The child program will run for some time(not fixed), but when theman pclose
child exits, the parent didn't get the SIGPIPE, so how to be notified
when the child is exit?
I don't think he wants to block. He wants to do other things, and get
notified when the child has exited, at which time he will call pclose().
You may be right but I see no clear evidence to that effect in the post.
The OP really should clarify. The way I read it, and the way I would
normally use popen("cmd", "w"), is that when I was done writing to the
pipe I'd close it, and then call pclose with confidence that it wouldn't
block for long. But there are of course scenarios which differ from this.
I didn't notice you reply because I thought the pclose() work just
like close(), now I reread the man manual and find that it will block
until the program exits! Its useful although I don't want block, as
Barry said I can use a thread to call pclose().
Or you can use fork/exec instead of popen (that's all popen does anyway)
and catch SIGCLD/SIGCHLD to determine when the program exits (or use
waitpid with NOHANG).
scott
.
- References:
- popen: how to know the child has exited?
- From: Bin Chen
- Re: popen: how to know the child has exited?
- From: Rex Mottram
- Re: popen: how to know the child has exited?
- From: Barry Margolin
- Re: popen: how to know the child has exited?
- From: Rex Mottram
- Re: popen: how to know the child has exited?
- From: Bin Chen
- popen: how to know the child has exited?
- Prev by Date: Re: advices on sockets
- Next by Date: Re: advices on sockets
- Previous by thread: Re: popen: how to know the child has exited?
- Next by thread: Re: popen: how to know the child has exited?
- Index(es):
Relevant Pages
|