new_perl
new_perl

Reputation: 7735

Error reported when running example from <Programming Perl>

pipe(FROM_PARENT, TO_CHILD) or die "pipe: $!";
pipe(FROM_CHILD, TO_PARENT) or die "pipe: $!";
select((select(TO_CHILD), $| = 1))[0]); # autoflush
select((select(TO_PARENT), $| = 1))[0]); # autoflush
if ($pid = fork) {
    close FROM_PARENT; close TO_PARENT;
    print TO_CHILD "Parent Pid $$ is sending this\n";
    chomp($line = <FROM_CHILD>);
    print "Parent Pid $$ just read this: `$line'\n";
    close FROM_CHILD; close TO_CHILD;
    waitpid($pid,0);
} else {
    die "cannot fork: $!" unless defined $pid;
    close FROM_CHILD; close TO_CHILD;
    chomp($line = <FROM_PARENT>);
    print "Child Pid $$ just read this: `$line'\n";
    print TO_PARENT "Child Pid $$ is sending this\n";
    close FROM_PARENT; close TO_PARENT;
    exit;
}

It reports Not enough arguments for select system call,

what does it mean?

Upvotes: 1

Views: 124

Answers (1)

Leonardo Herrera
Leonardo Herrera

Reputation: 8406

That looks like a typo. The actual code should look like this:

select((select(TO_CHILD), ($| = 1))[0]); # autoflush
select((select(TO_PARENT), ($| = 1))[0]); # autoflush

Upvotes: 3

Related Questions