I have been assuming that the 'correct' behavior of perl is that when perl calls die while it is running a command via bacticks that perl kills whatever was run by the backtick command.

is that a correct assumption?

-----Original message-----
From: Uri Guttman <[email protected]>
To: Greg London <[email protected]>
Cc: [email protected]
Sent: Mon, Jul 18, 2011 21:49:47 GMT+00:00
Subject: Re: [Boston.pm] backticks tee'd to stdout ?

"GL" == Greg London <Greg> writes:

 GL> Is there an easy way to tweak backticks so it still captures the
 GL> output but also tees the output to stdout?

you can pipe a command to tee and save it to a file and also to
stdout. the file could be /dev/tty which is the console

you can use open "$cmd|" and read the handle line by line. then print
each line to stdout and append it to a buffer for processing.

GL> also, the command that is hanging, I set an ALRM that has 'die' as its GL> callback. but I end up with the backtick command.running as a zombie GL> process. I have no idea why its doing that. but I dont think I have ever GL> used ALRM either.

possibly because your command has shell chars in it so first a shell is
spawned and it runs your program. you may be killing the shell but not
reaping its child. you can reap it with a SIGCHLD handler. or if you use
the pipe idea above you will get its pid from the open and be able to
kill the process directly if it times out.

uri

--
Uri Guttman -- uri AT perlhunter DOT com --- http://www.perlhunter.com -- ------------ Perl Developer Recruiting and Placement Services ------------- ----- Perl Code Review, Architecture, Development, Training, Support -------


_______________________________________________
Boston-pm mailing list
[email protected]
http://mail.pm.org/mailman/listinfo/boston-pm

Reply via email to