Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Re^7: How to tell a child what to do?

by Eyck (Priest)
on Sep 23, 2005 at 07:07 UTC ( #494420=note: print w/replies, xml ) Need Help??


in reply to Re^6: How to tell a child what to do?
in thread How to tell a child what to do?

I think, that if you rewrite this with sysread/syswrite, or, like in merlyn's solution with length-based communication, it starts working.

This may have something to do with perl's buffering, in particular, when instead of while (<>) I wrote this:

my $q; $q=<STDIN>; print "Received(child $$): $q\n";
it stopped hanging on close($fd).

When I traced what is happening when it hangs, it looks like parent is waiting waitpid(..) (close($fd) on pipe is supposed to do that), while child blissfully unaware is running read...

Now I can safely go and try to understand merlyn's code.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://494420]
help
Chatterbox?
[Discipulus]: new $workstation is arrived: SSD 250, sata 1TB, 16G RAM, only i5 CPU.. seems a good one: guess what first user installation will be?
[Corion]: Discipulus: Notepad++, or Perl ;)
[marto]: xubuntu or lubuntu
[Corion]: :-D
[marto]: my desktop is a core2 duo, 120GB SSD, 4GB RAM, boots to (GUI) login in less than 10 seconds from cold start
[Discipulus]: mah, winbuntu 10...
[marto]: whent he boys start school I'll build myself as new machine, ryzen based

How do I use this? | Other CB clients
Other Users?
Others imbibing at the Monastery: (5)
As of 2017-07-27 08:50 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    I came, I saw, I ...
























    Results (407 votes). Check out past polls.