prakash@fyrpwr.enet.dec.com (Mayank Prakash) (03/16/91)
-- I had a perl script in which I opened a file thus open(FOO, "| filter"); and then did a bunch of writes to FOO. My script exited by just falling through the end, and the output never got to the filter. Finally, I put a close(FOO); at the end of the script, and it worked. Should all filehandles be closed before exiting? -mayank. +--------------------------------------------------------------------------+ | InterNet: Prakash@AIAG.ENET.DEC.COM | | UUCP: ...!decwrl!aiag.enet.dec.com!Prakash | | VoiceNet: (508)490.8139 | | BitNet: prakash%aiag.enet at decwrl.dec.com | | SnailNet: DEC, 290 Donald Lynch Blvd. DLB5-2/B4, Marlboro, MA 01752-0749 | +--------------------------------------------------------------------------+ Disclaimer: The above is probably only line noise, and does not reflect the opinions of anybody, including mine, far less my employer's.
lwall@jpl-devvax.jpl.nasa.gov (Larry Wall) (03/16/91)
In article <21156@shlump.nac.dec.com> prakash@aiag.enet.dec.com writes:
: I had a perl script in which I opened a file thus
:
: open(FOO, "| filter");
:
: and then did a bunch of writes to FOO. My script exited by just
: falling through the end, and the output never got to the filter.
: Finally, I put a
:
: close(FOO);
:
: at the end of the script, and it worked. Should all filehandles be closed
: before exiting?
Ordinarily you don't need to do that, unless you want the Perl script to
wait for your filter to complete. I just did
open(FOO,"| (sleep 15; cat)");
print FOO "howdy\n";
and it worked fine falling off the end of the script. I can't imagine why
yours wouldn't work unless you've got #define exit _exit somewhere.
Ordinarily C's exit() will flush stdio buffers for you.
Larry