Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Death message in the middle of output

Status
Not open for further replies.

Nebbish

Programmer
Apr 7, 2004
73
US
I've encountered a curious problem in both Multiedit and Crimson Editor with Perl's "die" function. When I run a script that prints (say, listing filenames as its processing them), a frame pops up in the bottom of the screen, showing me what's in the STDOUT as it comes up--which is fine and dandy. However, if it encounteres a "die", the message associated with the die will appear right in the middle of the output, and only the error type will appear at the end. So, at the very end of the STDOUT you might see:

At file alsdlkrj.txt
At file asldkrjasdtliu.txt
At file blahblah.txt
Terminated with exit code 9

Now, when I scroll up to about 2/3rds down the STDOUT window, I see:

At file asdrlkjgad.txt
AtFile descriptors didn't match gafpmd.txt
At file asdalrkadjtdij.txt

Where "File descriptors didn't match" is the message associated with the encountered "die" function. Interestingly, when I run this from a windows shell this doesn't happen--the die message appears at the end where it should.

My guess is some funky flushing is going on. Any thoughts?
 
Have you been changing the value of $|, if so, question answered, funky flushing... but whether it's set in the editor to "save" the user from themselves is another thing

Haven't come across it - Textpad hasn't done it yet

--Paul

 
I hadn't been tampering with it, but I just tried setting it to 1 (no buffering) and the problem went away. The downside is the program prints about four times more slowly now.

Still, why does die force itself before the contents of the buffer? I'd really like to keep buffering enabled if at all possible.
 
The program will be run in a console window in production though, so you you've got a small PITB during development...

Sell it as an extra enhancement for tuning the script, by not running it in the editor (hnnh hhnnhh)

icrf is the dude for buffering advice, I think something like this came up some time ago

HTH
--Paul
 
Fortunately I'm the only person who will ever run this script, so it's not really a big deal if it goes unperfected. The best way I could find to get around it was to put:

$| = 1;

Directly before the die call. This makes sure all the buffers are cleaned out before the die kills itself, but still allows for buffering to occur before then. The downside to this is that I have to do it before every die, which I tend to have a lot of :(.

Thanks for your help...any words of advice on how to make this a one-statement fix, I'm all ears.

Nick

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top