cavac has asked for the wisdom of the Perl Monks concerning the following question:
Either i found a bug or i'm doing something incredibly stupid (my guess is the "stupidity").
I'm using a non-blocking client with IO::Socket::UNIX. Sometimes the script just exits without any error message, even though i'm trying to catch that specific case with an eval. Here is the relevant code:
print "Write to backend $clientid\n"; my $written; eval { print "AAAA\n"; $written = syswrite($clients{$clientid}->{backendsocket}, $clients +{$clientid print "BBBB\n"; }; print "X\n"; if($EVAL_ERROR) { print "Backend write error: $EVAL_ERROR\n"; push @toremove, $clientid; next; }
Most of the time this works fine, but sometimes i just get:
Write to backend someclientid AAAA
And then i'm back at the command line without any additional message. Shouldn't eval catch any errors and prevent the script from exiting?
If something goes wrong in syswrite, i'd expect an output like this:
Write to backend someclientid AAAA X Backend write error: some_error_message
What am i doing wrong here?
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: IO::Socket::UNIX plus syswrite plus eval fails?
by Corion (Patriarch) on Jun 02, 2021 at 11:48 UTC | |
by cavac (Prior) on Jun 02, 2021 at 12:05 UTC |