Extracted at 2014-06-26.
pike.ida.liu.se
[Top]
Tools
Tools.Application
Tools.Application.Backgrounder

Method Tools.Application.Backgrounder()->enter_background()


Method enter_background

int enter_background(int(0..1) should_we, string logfile, void|int(0..1) quiet)

Description

Cause this program to enter the background.

Parameter should_we

an integer that determines whether the process should be backgrounded or not

Parameter logfile

a string pointing to a log file that stdout and stderr will be written to

Returns

1 if the parent has successfully backgrounded a child, 0 if already in the background or don't need to enter the background.

Note

when this function returns true (1), this means we're in the foreground process (and a daemon was spawned and should therefore exit() the program as expeditiously as possible. Otherwise, the process is in the background and should continue on with normal operations.

If, after calling enter_background() , an application needs to know whether the application is operating as a daemon or not, in_background() may be used.

Note

because of the way certain functionality is emulated on systems without fork() , applications using this class should be careful to limit the amount of work performed before this method is called. Specifically, anything performed should be "side-effect" free, as the work will effectively be performed twice. Thus, it's probably best to limit pre-background operations to the bare minimum, such as parsing arguments (but not acting on them, except perhaps to determine if backgrounding has been requested, etc).