in reply to Re^3: Detecting forground and background process
in thread Detecting forground and background process
Good, but not sufficient. Input may come from a pipe or a file, so you also should check STDOUT. But even that is not sufficient, because STDOUT could be redirected or piped, too, so you may also want to check STDERR. And, you may already have guessed that, even that is not sufficient, as also STDERR can be piped or redirected.
If you have a dual-mode script that can work both as a daemon ("background process") and as an interactive command, use a command line switch for the daemon mode. Make the daemon starter (daemontools, init, srvany.exe) pass that switch to your command. Alternatively, use a symbolic link and decide based on $0, or use two scripts that have their shared code in one or more modules.
Alexander
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^5: Detecting forground and background process
by almut (Canon) on Jul 20, 2010 at 14:49 UTC | |
by afoken (Chancellor) on Jul 20, 2010 at 16:16 UTC |