Package org.apache.tomcat.jni
Class Proc
java.lang.Object
org.apache.tomcat.jni.Proc
Proc
- Author:
- Mladen Turk
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intstatic final intstatic final intstatic final intwait forever for the process to completestatic final intSIGTERM, wait 3 seconds, SIGKILLstatic final intprocess is sent SIGKILL on apr_pool_t cleanupstatic final intprocess is never sent any signalsstatic final intsend SIGTERM and then waitstatic final intstatic final intstatic final intstatic final intstatic final intprocess exited and dumped a core filestatic final intwait for the specified process to finishstatic final intchild has died, caller must call unregister stillstatic final intsomehow the child exited without us knowing ... buggy os?static final inta restart is occurring, perform any necessary cleanup (including sending a special signal to child)static final inta health check is occurring, for most maintenance functions this is a no-op.static final intunregister has been called, do whatever is necessary (including kill the child)static final intwrite_fd is unwritablestatic final intstatic final intDo not detachstatic final intstatic final intdo not wait -- just see if it has finishedstatic final intprocess exited normallystatic final intprocess exited due to a signalstatic final intuse the shell to invoke the programstatic final intinvoke the program directly, no copied envstatic final intinvoke the program, replicating our environmentstatic final intstatic final intfind program on PATH, use our environmentstatic final intuse the shell to invoke the program, replicating our environmentstatic final intDetachstatic final int -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic longalloc(long cont) Allocate apr_proc_t structure from pool This is not an apr function.static intCreate a new process and execute a new program within that process.static intdetach(int daemonize) Detach the process from the controlling terminal.static intfork(long[] proc, long cont) This is currently the only non-portable call in APR.static intkill(long proc, int sig) Terminate a process.static intwait(long proc, int[] exit, int waithow) Wait for a child process to diestatic intwaitAllProcs(long proc, int[] exit, int waithow, long pool) Wait for any current child process to die and return information about that child.
-
Field Details
-
APR_SHELLCM
public static final int APR_SHELLCM- See Also:
-
APR_PROGRAM
public static final int APR_PROGRAMuse the shell to invoke the program- See Also:
-
APR_PROGRAM_ENV
public static final int APR_PROGRAM_ENVinvoke the program directly, no copied env- See Also:
-
APR_PROGRAM_PATH
public static final int APR_PROGRAM_PATHinvoke the program, replicating our environment- See Also:
-
APR_SHELLCMD_ENV
public static final int APR_SHELLCMD_ENVfind program on PATH, use our environment- See Also:
-
APR_WAIT
public static final int APR_WAITuse the shell to invoke the program, replicating our environment- See Also:
-
APR_NOWAIT
public static final int APR_NOWAITwait for the specified process to finish- See Also:
-
APR_PROC_EXIT
public static final int APR_PROC_EXITdo not wait -- just see if it has finished- See Also:
-
APR_PROC_SIGNAL
public static final int APR_PROC_SIGNALprocess exited normally- See Also:
-
APR_PROC_SIGNAL_CORE
public static final int APR_PROC_SIGNAL_COREprocess exited due to a signal- See Also:
-
APR_NO_PIPE
public static final int APR_NO_PIPEprocess exited and dumped a core file- See Also:
-
APR_FULL_BLOCK
public static final int APR_FULL_BLOCK- See Also:
-
APR_FULL_NONBLOCK
public static final int APR_FULL_NONBLOCK- See Also:
-
APR_PARENT_BLOCK
public static final int APR_PARENT_BLOCK- See Also:
-
APR_CHILD_BLOCK
public static final int APR_CHILD_BLOCK- See Also:
-
APR_LIMIT_CPU
public static final int APR_LIMIT_CPU- See Also:
-
APR_LIMIT_MEM
public static final int APR_LIMIT_MEM- See Also:
-
APR_LIMIT_NPROC
public static final int APR_LIMIT_NPROC- See Also:
-
APR_LIMIT_NOFILE
public static final int APR_LIMIT_NOFILE- See Also:
-
APR_OC_REASON_DEATH
public static final int APR_OC_REASON_DEATHchild has died, caller must call unregister still- See Also:
-
APR_OC_REASON_UNWRITABLE
public static final int APR_OC_REASON_UNWRITABLEwrite_fd is unwritable- See Also:
-
APR_OC_REASON_RESTART
public static final int APR_OC_REASON_RESTARTa restart is occurring, perform any necessary cleanup (including sending a special signal to child)- See Also:
-
APR_OC_REASON_UNREGISTER
public static final int APR_OC_REASON_UNREGISTERunregister has been called, do whatever is necessary (including kill the child)- See Also:
-
APR_OC_REASON_LOST
public static final int APR_OC_REASON_LOSTsomehow the child exited without us knowing ... buggy os?- See Also:
-
APR_OC_REASON_RUNNING
public static final int APR_OC_REASON_RUNNINGa health check is occurring, for most maintenance functions this is a no-op.- See Also:
-
APR_KILL_NEVER
public static final int APR_KILL_NEVERprocess is never sent any signals- See Also:
-
APR_KILL_ALWAYS
public static final int APR_KILL_ALWAYSprocess is sent SIGKILL on apr_pool_t cleanup- See Also:
-
APR_KILL_AFTER_TIMEOUT
public static final int APR_KILL_AFTER_TIMEOUTSIGTERM, wait 3 seconds, SIGKILL- See Also:
-
APR_JUST_WAIT
public static final int APR_JUST_WAITwait forever for the process to complete- See Also:
-
APR_KILL_ONLY_ONCE
public static final int APR_KILL_ONLY_ONCEsend SIGTERM and then wait- See Also:
-
APR_PROC_DETACH_FOREGROUND
public static final int APR_PROC_DETACH_FOREGROUND- See Also:
-
APR_PROC_DETACH_DAEMONIZE
public static final int APR_PROC_DETACH_DAEMONIZEDo not detach- See Also:
-
MAX_ARGS_SIZE
public static final int MAX_ARGS_SIZEDetach- See Also:
-
MAX_ENV_SIZE
public static final int MAX_ENV_SIZE- See Also:
-
-
Constructor Details
-
Proc
public Proc()
-
-
Method Details
-
alloc
public static long alloc(long cont) Allocate apr_proc_t structure from pool This is not an apr function.- Parameters:
cont- The pool to use.- Returns:
- the pointer
-
fork
public static int fork(long[] proc, long cont) This is currently the only non-portable call in APR. This executes a standard unix fork.- Parameters:
proc- The resulting process handle.cont- The pool to use.- Returns:
- APR_INCHILD for the child, and APR_INPARENT for the parent or an error.
-
create
public static int create(long proc, String progname, String[] args, String[] env, long attr, long pool) Create a new process and execute a new program within that process. This function returns without waiting for the new process to terminate; use apr_proc_wait for that.- Parameters:
proc- The process handleprogname- The program to runargs- The arguments to pass to the new program. The first one should be the program name.env- The new environment table for the new process. This should be a list of NULL-terminated strings. This argument is ignored for APR_PROGRAM_ENV, APR_PROGRAM_PATH, and APR_SHELLCMD_ENV types of commands.attr- The procattr we should use to determine how to create the new processpool- The pool to use.- Returns:
- The resulting process handle.
-
wait
public static int wait(long proc, int[] exit, int waithow) Wait for a child process to die- Parameters:
proc- The process handle that corresponds to the desired child processexit- exit[0] The returned exit status of the child, if a child process dies, or the signal that caused the child to die. On platforms that don't support obtaining this information, the status parameter will be returned as APR_ENOTIMPL. exit[1] Why the child died, the bitwise or of:APR_PROC_EXIT -- process terminated normally APR_PROC_SIGNAL -- process was killed by a signal APR_PROC_SIGNAL_CORE -- process was killed by a signal, and generated a core dump.waithow- How should we wait. One of:APR_WAIT -- block until the child process dies. APR_NOWAIT -- return immediately regardless of if the child is dead or not.- Returns:
- The childs status is in the return code to this process. It is one of:
APR_CHILD_DONE -- child is no longer running. APR_CHILD_NOTDONE -- child is still running.
-
waitAllProcs
public static int waitAllProcs(long proc, int[] exit, int waithow, long pool) Wait for any current child process to die and return information about that child.- Parameters:
proc- Pointer to NULL on entry, will be filled out with child's informationexit- exit[0] The returned exit status of the child, if a child process dies, or the signal that caused the child to die. On platforms that don't support obtaining this information, the status parameter will be returned as APR_ENOTIMPL. exit[1] Why the child died, the bitwise or of:APR_PROC_EXIT -- process terminated normally APR_PROC_SIGNAL -- process was killed by a signal APR_PROC_SIGNAL_CORE -- process was killed by a signal, and generated a core dump.waithow- How should we wait. One of:APR_WAIT -- block until the child process dies. APR_NOWAIT -- return immediately regardless of if the child is dead or not.pool- Pool to allocate child information out of.- Returns:
- the operation status
-
detach
public static int detach(int daemonize) Detach the process from the controlling terminal.- Parameters:
daemonize- set to non-zero if the process should daemonize and become a background process, else it will stay in the foreground.- Returns:
- the operation status
-
kill
public static int kill(long proc, int sig) Terminate a process.- Parameters:
proc- The process to terminate.sig- How to kill the process.- Returns:
- the operation status
-