Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change

Re: How to know if a perl script is put in the background

by mifflin (Curate)
on Nov 18, 2008 at 20:56 UTC ( #724382=note: print w/replies, xml ) Need Help??

in reply to How to know if a perl script is put in the background

I think I read in "Perl Best Practices" that using -t is not always accurate. The author (Damian Conway) suggests using something like this...

use IO::Interactive qw(is_interactive); if ( is_interactive() ) { print "Running interactively\n"; }

Replies are listed 'Best First'.
Re^2: How to know if a perl script is put in the background (background vs. non-interactive)
by almut (Canon) on Nov 18, 2008 at 21:58 UTC

    Looking at the implementation of IO::Interactive, it's essentially -t plus some code to handle *ARGV magicness. In other words, it shares the same problem of possibly producing incorrect results when being (mis)used to test if something is running in the background (e.g. when a script is sent into the background using &, executed from an (interactive) command line):

    $ ./ Running interactively $ stty -tostop # just in case $ ./ & [1] 13831 $ Running interactively [1]+ Done ./

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://724382]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others perusing the Monastery: (8)
As of 2016-10-21 21:35 GMT
Find Nodes?
    Voting Booth?
    How many different varieties (color, size, etc) of socks do you have in your sock drawer?

    Results (291 votes). Check out past polls.