R
Robert Jacobson
I'm having some trouble figuring out an error that I'm getting.
syswrite is failing to write; $! is "Bad file descriptor". What
boggles my mind is that this is after some data had already been
written successfully to the file handle!
This problem seems to be linked to a recent change I made to my
program. My program is basically a network socket data collector,
running on Windows with ActivePerl 5.8.8 (build 819)
- open data file (sysopen)
- connect to server socket
- while read from server socket OK
- write data to file
- if X time elapsed:
- close file
- open new file
I recently changed my program to add "use threads", and add a
conversion program in that thread
....
- if X time elapsed:
- close file
- new thread for &convert_file(). I call $thread->detach
immediately after creation
- open new file
After I made the above change, syswrite started *occassionally*
returning undef, and setting $! to "Bad file descriptor". Again, most
of the time it works. When it fails, it does seem to be while
convert_file() is still running. It takes about 10 seconds to convert
the file; that's why I'm using a separate thread. The program writes
about 400 kB to the file, then I get the "Bad file descriptor" error.
For kicks, I tried changing syswrite() to print(), but it also seems
to be having trouble.
So, what should my next troubleshooting steps be?
syswrite is failing to write; $! is "Bad file descriptor". What
boggles my mind is that this is after some data had already been
written successfully to the file handle!
This problem seems to be linked to a recent change I made to my
program. My program is basically a network socket data collector,
running on Windows with ActivePerl 5.8.8 (build 819)
- open data file (sysopen)
- connect to server socket
- while read from server socket OK
- write data to file
- if X time elapsed:
- close file
- open new file
I recently changed my program to add "use threads", and add a
conversion program in that thread
....
- if X time elapsed:
- close file
- new thread for &convert_file(). I call $thread->detach
immediately after creation
- open new file
After I made the above change, syswrite started *occassionally*
returning undef, and setting $! to "Bad file descriptor". Again, most
of the time it works. When it fails, it does seem to be while
convert_file() is still running. It takes about 10 seconds to convert
the file; that's why I'm using a separate thread. The program writes
about 400 kB to the file, then I get the "Bad file descriptor" error.
For kicks, I tried changing syswrite() to print(), but it also seems
to be having trouble.
So, what should my next troubleshooting steps be?