Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??

From perldoc -f eof

Note that this function actually reads a character and then "ungetc"s it, so isn't useful in an interactive context.
What I would do instead:

#!/usr/bin/perl use strict; # https://perlmonks.org/?node_id=11123397 use warnings; use Socket; my $child; #filehandle to child process my $parent; #filehandle to parent process my $pid; #Process ID of child process socketpair($child, $parent, AF_UNIX, SOCK_STREAM, PF_UNSPEC) or die "socketpair: $! +"; $child->autoflush(1); $parent->autoflush(1); if ($pid = fork()) { close $parent or die "close: $!\n"; sleep 1; print STDOUT time%1000, ": polling child\n"; my $buf = ''; while( sysread $child, $buf, 4096, length $buf ) { while( $buf =~ s/(.*)\n// ) { print STDOUT time%1000, ": received <$1>\n"; } } print STDOUT time%1000, ": end of input from child\n"; wait; } elsif( defined $pid ) { close $child or die "close: $!\n"; print STDOUT time%1000, ": child started\n"; sleep 5; print $parent time%1000, ": child printed\n"; close $parent or die "close: $!\n"; exit; } else { die "cannot fork: $!"; }

In reply to Re: eof() blocking by tybalt89
in thread eof() blocking by azadian

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others studying the Monastery: (5)
As of 2024-03-29 07:36 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found