Detect background processing
Posted on 1997-04-22
I.E. Within my perl script, if I'm running as a foreground
process then I want to give the user the option to alter the setup. If the script is run as a background process then it runs with defaults set.
I've had numerous suggestions from checking the $SHELL env var to the -t test operator to system("tty -s") and checking $? var. These can all distingush between running as a foreground process or as a cron/at process but they don't work for background process spawn via nohup or & from a foreground shell process. i.e. they inherit from the parent shell.