|
static void | Initialize () |
|
static JThisProcess * | Instance () |
|
static JError | Fork (pid_t *pid) |
|
static void | Exit (const int returnValue) |
|
static void | Abort () |
|
static bool | WillQuitAtExit (const JProcess *p) |
|
static void | QuitAtExit (JProcess *p, const bool quit=true) |
|
static bool | WillKillAtExit (const JProcess *p) |
|
static void | KillAtExit (JProcess *p, const bool kill=true) |
|
static void | Ignore (JProcess *p) |
|
static bool | WillCatchSignal (const int sig) |
|
static void | ShouldCatchSignal (const int sig, const bool catchIt) |
|
static bool | CheckForSignals () |
|
static void | ChildExecFailed () |
|
static void | CheckACEReactor () |
|
static jmp_buf & | GetSigintJumpBuffer () |
|
static JError | Create (JProcess **process, const JString &str, const JExecuteAction toAction=kJIgnoreConnection, int *toFD=nullptr, const JExecuteAction fromAction=kJIgnoreConnection, int *fromFD=nullptr, const JExecuteAction errAction=kJIgnoreConnection, int *errFD=nullptr) |
|
static JError | Create (JProcess **process, const JPtrArray< JString > &argList, const JExecuteAction toAction=kJIgnoreConnection, int *toFD=nullptr, const JExecuteAction fromAction=kJIgnoreConnection, int *fromFD=nullptr, const JExecuteAction errAction=kJIgnoreConnection, int *errFD=nullptr) |
|
static JError | Create (JProcess **process, const JUtf8Byte *argv[], const JSize size, const JExecuteAction toAction=kJIgnoreConnection, int *toFD=nullptr, const JExecuteAction fromAction=kJIgnoreConnection, int *fromFD=nullptr, const JExecuteAction errAction=kJIgnoreConnection, int *errFD=nullptr) |
|
static JError | Create (JProcess **process, const JString &workingDirectory, const JString &str, const JExecuteAction toAction=kJIgnoreConnection, int *toFD=nullptr, const JExecuteAction fromAction=kJIgnoreConnection, int *fromFD=nullptr, const JExecuteAction errAction=kJIgnoreConnection, int *errFD=nullptr) |
|
static JError | Create (JProcess **process, const JString &workingDirectory, const JPtrArray< JString > &argList, const JExecuteAction toAction=kJIgnoreConnection, int *toFD=nullptr, const JExecuteAction fromAction=kJIgnoreConnection, int *fromFD=nullptr, const JExecuteAction errAction=kJIgnoreConnection, int *errFD=nullptr) |
|
static JError | Create (JProcess **process, const JString &workingDirectory, const JUtf8Byte *argv[], const JSize size, const JExecuteAction toAction=kJIgnoreConnection, int *toFD=nullptr, const JExecuteAction fromAction=kJIgnoreConnection, int *fromFD=nullptr, const JExecuteAction errAction=kJIgnoreConnection, int *errFD=nullptr) |
|
static void | CheckForFinishedChild (const bool block) |
|
Interface for the JThisProcess class
Class to represent one's own UNIX process and catch signals. This class
is designed to be a single, global object, accessible via
JThisProcess::Instance().
Event loops can call CheckForSignals() in order to convert signals into
JBroadcaster messages. The messages are broadcast in the order that
the signals were received and are caught via ReceiveWithFeedback() so
that the one who handles the signal can indicate this by calling
SetCaught() before returning.
Only the first 32 signals that are received will actually be broadcast.
This shouldn't be a problem unless the event loop is blocked and the
program relies heavily on signals, neither of which should happen in a
well-designed program, I think. Let me know if you need more.
You can change which signals are caught by calling ShouldCatchSignal().
The signals that are caught by default are:
Signal Action Description
------------------------------------------------------
SIGPIPE Broken pipe: write to pipe with no readers
(non-fatal because no control over when other end dies)
SIGTERM Q Termination signal
SIGQUIT Q Quit from keyboard
SIGINT D Interrupt from keyboard
SIGHUP Hangup detected on controlling terminal
or death of controlling process
SIGCHLD Child stopped or terminated
SIGTTIN tty input for background process
SIGTTOU tty output for background process
SIGALRM Timer signal from alarm(1)
SIGUSR1 User-defined signal 1
SIGUSR2 User-defined signal 2
A = Abort if the signal is not caught.
Q = Cause CheckForSignals() to return true,
as a suggestion to the event loop to quit,
if the signal is not caught.
D = Clean up child processes that should quit or be killed
and then die
The signals that are not caught by default are:
Signal Description Reason
------------------------------------------------------
SIGSEGV Invalid memory reference How does one recover?
SIGFPE Floating point exception How does one recover?
SIGILL Illegal Instruction How does one recover?
The signals that should never be caught are:
Signal Description Reason
------------------------------------------------------
SIGKILL Kill signal Can't be caught
SIGCONT Continue if stopped It does the right thing already
SIGSTOP Stop process Can't be caught
SIGTSTP Stop typed at tty Catching this means Ctrl-Z won't work
SIGABRT Abort signal from abort(3) assert() calls abort()
abort() generates infinite # of SIGABRT's
We provide GetSigintJumpBuffer() so SIGINT handler can longjmp() back
to JXApplication(), call CleanUpBeforeSuddenDeath(), and then exit().