Mailing List Archive

Dieing inside syswrite
I have a script that copies files over a socket. In the perl 4 version, it
used read() and syswrite(). In perl 5, if I use read(), I wind up causing a
connection problem later on (dunno why, but it's too difficult to explain here
and not germane to the question I come to you with). So I switched to sysread.
Now, the script spontaneously (but consistently) dies inside of syswrite.
Usually by the 5th or 6th packet from sysread(). I have debug markers
bracketing the syswrite, so I know that's where it's at. Here's the cute part:

Normal operation (where it dies consistently) is to write the data to a pipe
opened on the uncompress command (possibly further piped to tar xf)

"Transfer-only" mode instead writes it straight to a file on disk. This mode
works, exact same loop, with no errors or unexpected death. Only difference is
that the write-to filehandle is a file rather than a write-only pipe.

I'm stumped, I'm going to work on something else for a while. Like needlepoint,
maybe.

Randy
--
^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^
Randy J. Ray -- U S WEST Technologies IAD/CSS/DPDS Phone: (303)607-5268
Denver, CO rjray@lookout.ecte.uswc.uswest.com

I don't suffer from insanity. I enjoy every minute of it.
Re: Dieing inside syswrite [ In reply to ]
Excerpts from the mail message of Randy J Ray:
) I have a script that copies files over a socket. In the perl 4 version, it
) used read() and syswrite(). In perl 5, if I use read(), I wind up causing a
) connection problem later on (dunno why, but it's too difficult to explain here
) and not germane to the question I come to you with). So I switched to sysread.
) Now, the script spontaneously (but consistently) dies inside of syswrite.
) Usually by the 5th or 6th packet from sysread(). I have debug markers
) bracketing the syswrite, so I know that's where it's at. Here's the cute part:
)
) Normal operation (where it dies consistently) is to write the data to a pipe
) opened on the uncompress command (possibly further piped to tar xf)

I'm pretty sure your data is getting corrupted and uncompress is
noticing and going away and Perl is getting a SIGPIPE and exiting
quietly. Add `` $SIG{PIPE}= sub { die "Broken pipe!" }; '' to
your script to find out.

Now you just need to figure out why sysread() is giving you different
data than read(). Perhaps your buffer size is too big? Perhaps you
aren't looking at the return value from sysread() which is telling
you that you only got part of what you were asking for?

--
Tye McQueen tye@metronet.com || tye@doober.usu.edu
Nothing is obvious unless you are overlooking something
http://www.metronet.com/~tye/ (scripts, links, nothing fancy)