Re: Read first few lines from command output
- From: Big and Blue <No_4@xxxxxxxxxxxxx>
- Date: Thu, 28 Jul 2005 01:41:24 +0100
>
I was wondering if there is a cleaner way to do this. The key is that I do not want to wait for the data command to complete.
As has been pointed out, it's the process generating the data which is sent the SIGPIPE and hence would need to handle it.
Since you don't want to wait in your script then, if you can't get the other side to handle SIGPIPE:
1) read as much as you need to 2) fork() 3) let the child continue to read (and discard) the rest of the input while 4) the parent continues to do what you want it to.
You may wish to get the child to fork twice (so the parent quickly sees its child die() and so won't wait for it), to close the read handle in the parent and to detach the child even more (eg: setsid from POSIX), but that is left up to you....
-- Just because I've written it doesn't mean that either you or I have to believe it. .
- References:
- Read first few lines from command output
- From: sp0_0ky
- Read first few lines from command output
- Prev by Date: Re: Split line into an array vs multiple strings
- Next by Date: Re: Read first few lines from command output
- Previous by thread: Re: Read first few lines from command output
- Next by thread: FAQ 4.2 Why is int() broken?
- Index(es):
Relevant Pages
|
|