J
John
All:
I have set up a named pipe to transfer data between threads. While the
transfer is successful, I'm perplexed by the system messages I trap along
the way. As a necessity, I start attempting to read from the pipe ahead
of writing to the pipe using:
<code snip>
do {
open (FIFO_READ, "< $FIFO");
if ($!) {
print "Exception: $! - sleeping 1 seconds and trying again\n";
sleep(1);
} # end if
else {
print "No exception...\n";
$exception_flag = 0;
} # end else
} until ( !$exception_flag ) ;
The output continues to be "Exception: No such file or directory -
sleeping 1 seconds and trying again" until something is written to the
pipe at which time the exception becomes:
"Exception: Illegal seek - sleeping 1 seconds and trying again"
At this point the data is transfered, but I find it odd that this is the
exception message at this point in the process.
The pipe for writing is created with:
<code snip>
my $FIFO = $path;
unless (-p $FIFO) { # unless the file is not a pipe
system('/bin/mknod', $FIFO, 'p')
&& die "can't mknod $FIFO: $!";
} # end unless
# next line blocks until there is a reader
open(FIFO_WRITE, "> $FIFO") || die "can't write $FIFO: $!";
print "WRITE_TO_PIPE - Writing $phrase to pipe: $phrase\n";
print FIFO_WRITE "$phrase\n";
close FIFO_WRITE;
sleep 1; # to avoid dup signals
I am interested to hear your thoughts about the messages I'm receiving.
If you believe that this question is better suited for a Linux newsgroup,
please let me know and I will move this question over there.
Thanks in advance!
John
I have set up a named pipe to transfer data between threads. While the
transfer is successful, I'm perplexed by the system messages I trap along
the way. As a necessity, I start attempting to read from the pipe ahead
of writing to the pipe using:
<code snip>
do {
open (FIFO_READ, "< $FIFO");
if ($!) {
print "Exception: $! - sleeping 1 seconds and trying again\n";
sleep(1);
} # end if
else {
print "No exception...\n";
$exception_flag = 0;
} # end else
} until ( !$exception_flag ) ;
The output continues to be "Exception: No such file or directory -
sleeping 1 seconds and trying again" until something is written to the
pipe at which time the exception becomes:
"Exception: Illegal seek - sleeping 1 seconds and trying again"
At this point the data is transfered, but I find it odd that this is the
exception message at this point in the process.
The pipe for writing is created with:
<code snip>
my $FIFO = $path;
unless (-p $FIFO) { # unless the file is not a pipe
system('/bin/mknod', $FIFO, 'p')
&& die "can't mknod $FIFO: $!";
} # end unless
# next line blocks until there is a reader
open(FIFO_WRITE, "> $FIFO") || die "can't write $FIFO: $!";
print "WRITE_TO_PIPE - Writing $phrase to pipe: $phrase\n";
print FIFO_WRITE "$phrase\n";
close FIFO_WRITE;
sleep 1; # to avoid dup signals
I am interested to hear your thoughts about the messages I'm receiving.
If you believe that this question is better suited for a Linux newsgroup,
please let me know and I will move this question over there.
Thanks in advance!
John