Re: unexpected quit - no error messageby almut (Canon)
|on Mar 02, 2009 at 16:44 UTC||Need Help??|
Just a wild guess... (anything else is hard without seeing the code :): your script might be trying to write to a closed socket (closed by the device). This generates a SIGPIPE signal, whose default handler action is to abort the program (assuming you're on Unix).
Consider this example
When you run this as is, it quits without printing "done.", because it's being terminated before. When you setup your own SIGPIPE handler, OTOH, you'd get your (self-generated) "Broken pipe" warning message, followed by "done."
(Note that this sample snippet would not exit with $? being zero (so this simple theory doesn't quite fit your case), but there are other circumstances conceivable where it might...)
How to debug? You could run your script under strace (a tool I tend to recommend at least twice a week here :) in order to figure out what your script is doing last... This would likely prove helpful anyway, even if my above theory is wrong.
E.g. in the above sample case, you'd see something like this at the end of the trace
(notice the write(8, "foo\n",... line which returns with EPIPE)