[Date Prev][Date Next] [Thread Prev][Thread Next]
[Thread Index]
[Date Index]
[Author Index]
Re: forked process exiting before output read
- From: "Jeffrey Ratcliffe" <jeffrey ratcliffe gmail com>
- To: gtk-perl-list gnome org
- Subject: Re: forked process exiting before output read
- Date: Tue, 31 Jul 2007 09:16:20 +0200
On 31/07/07, muppet <scott asofyet org> wrote:
> Is it the handling in the parent that takes a while, or in the
> child? I notice you have a sleep(2) in the loop in the gui,
> presumably to simulate the gui taking al ong time...
A bit of both. It seems to depend on what the rest of the system is
doing, but 25% of the time, I definitely had the problem that the GUI
in the parent wasn't keeping up with the child.
> With some very minor changes, i get this example to work just fine.
> (No need to go dorking around with the insanity of threads... ;-)
Thanks!
> If small lines of text are what you have, you might actually want to
> use datagram sockets, because you'll get guaranteed delivery of
> entire messages.
Never heard of those before, but google is my friend. So to do this, I change:
socketpair($reader, $writer, AF_UNIX, SOCK_STREAM, PF_UNSPEC);
[..]
$line = <$reader>;
[..]
$writer->write($i/$n."Running $i of $n\n");
$writer->flush;
to
socketpair($reader, $writer, AF_UNIX, SOCK_DGRAM, PF_UNSPEC);
[..]
recv($reader, $line, 1000, 0);
[..]
send($writer, $i/$n."Running $i of $n\n", 0);
Seems to work fine. Thanks.
Do I need to worry about the flags in send and recv?
Jeff
[Date Prev][Date Next] [Thread Prev][Thread Next]
[Thread Index]
[Date Index]
[Author Index]