Proc (Apache Tomcat 8.5.57 API Documentation)

org.apache.tomcat.jni

## Class Proc

- java.lang.Object
- - org.apache.tomcat.jni.Proc

-     public class Proc
      extends Object

  Proc
  Author:
    Mladen Turk

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static int` | `APR_CHILD_BLOCK`
    `static int` | `APR_FULL_BLOCK`
    `static int` | `APR_FULL_NONBLOCK`
    `static int` | `APR_JUST_WAIT` wait forever for the process to complete
    `static int` | `APR_KILL_AFTER_TIMEOUT` SIGTERM, wait 3 seconds, SIGKILL
    `static int` | `APR_KILL_ALWAYS` process is sent SIGKILL on apr_pool_t cleanup
    `static int` | `APR_KILL_NEVER` process is never sent any signals
    `static int` | `APR_KILL_ONLY_ONCE` send SIGTERM and then wait
    `static int` | `APR_LIMIT_CPU`
    `static int` | `APR_LIMIT_MEM`
    `static int` | `APR_LIMIT_NOFILE`
    `static int` | `APR_LIMIT_NPROC`
    `static int` | `APR_NO_PIPE` process exited and dumped a core file
    `static int` | `APR_NOWAIT` wait for the specified process to finish
    `static int` | `APR_OC_REASON_DEATH` child has died, caller must call unregister still
    `static int` | `APR_OC_REASON_LOST` somehow the child exited without us knowing ... buggy os?
    `static int` | `APR_OC_REASON_RESTART` a restart is occurring, perform any necessary cleanup (including sending a special signal to child)
    `static int` | `APR_OC_REASON_RUNNING` a health check is occurring, for most maintenance functions this is a no-op.
    `static int` | `APR_OC_REASON_UNREGISTER` unregister has been called, do whatever is necessary (including kill the child)
    `static int` | `APR_OC_REASON_UNWRITABLE` write_fd is unwritable
    `static int` | `APR_PARENT_BLOCK`
    `static int` | `APR_PROC_DETACH_DAEMONIZE` Do not detach
    `static int` | `APR_PROC_DETACH_FOREGROUND`
    `static int` | `APR_PROC_EXIT` do not wait -- just see if it has finished
    `static int` | `APR_PROC_SIGNAL` process exited normally
    `static int` | `APR_PROC_SIGNAL_CORE` process exited due to a signal
    `static int` | `APR_PROGRAM` use the shell to invoke the program
    `static int` | `APR_PROGRAM_ENV` invoke the program directly, no copied env
    `static int` | `APR_PROGRAM_PATH` invoke the program, replicating our environment
    `static int` | `APR_SHELLCM`
    `static int` | `APR_SHELLCMD_ENV` find program on PATH, use our environment
    `static int` | `APR_WAIT` use the shell to invoke the program, replicating our environment
    `static int` | `MAX_ARGS_SIZE` Detach
    `static int` | `MAX_ENV_SIZE`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `Proc()`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `static long` | `alloc(long cont)` Allocate apr_proc_t structure from pool This is not an apr function.
    `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.
    `static int` | `detach(int daemonize)` Detach the process from the controlling terminal.
    `static int` | `fork(long[] proc, long cont)` This is currently the only non-portable call in APR.
    `static int` | `kill(long proc, int sig)` Terminate a process.
    `static int` | `wait(long proc, int[] exit, int waithow)` Wait for a child process to die
    `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.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### APR_SHELLCM

          public static final int APR_SHELLCM

      See Also:
        Constant Field Values

    - #### APR_PROGRAM

          public static final int APR_PROGRAM

      use the shell to invoke the program
      See Also:
        Constant Field Values

    - #### APR_PROGRAM_ENV

          public static final int APR_PROGRAM_ENV

      invoke the program directly, no copied env
      See Also:
        Constant Field Values

    - #### APR_PROGRAM_PATH

          public static final int APR_PROGRAM_PATH

      invoke the program, replicating our environment
      See Also:
        Constant Field Values

    - #### APR_SHELLCMD_ENV

          public static final int APR_SHELLCMD_ENV

      find program on PATH, use our environment
      See Also:
        Constant Field Values

    - #### APR_WAIT

          public static final int APR_WAIT

      use the shell to invoke the program, replicating our environment
      See Also:
        Constant Field Values

    - #### APR_NOWAIT

          public static final int APR_NOWAIT

      wait for the specified process to finish
      See Also:
        Constant Field Values

    - #### APR_PROC_EXIT

          public static final int APR_PROC_EXIT

      do not wait -- just see if it has finished
      See Also:
        Constant Field Values

    - #### APR_PROC_SIGNAL

          public static final int APR_PROC_SIGNAL

      process exited normally
      See Also:
        Constant Field Values

    - #### APR_PROC_SIGNAL_CORE

          public static final int APR_PROC_SIGNAL_CORE

      process exited due to a signal
      See Also:
        Constant Field Values

    - #### APR_NO_PIPE

          public static final int APR_NO_PIPE

      process exited and dumped a core file
      See Also:
        Constant Field Values

    - #### APR_FULL_BLOCK

          public static final int APR_FULL_BLOCK

      See Also:
        Constant Field Values

    - #### APR_FULL_NONBLOCK

          public static final int APR_FULL_NONBLOCK

      See Also:
        Constant Field Values

    - #### APR_PARENT_BLOCK

          public static final int APR_PARENT_BLOCK

      See Also:
        Constant Field Values

    - #### APR_CHILD_BLOCK

          public static final int APR_CHILD_BLOCK

      See Also:
        Constant Field Values

    - #### APR_LIMIT_CPU

          public static final int APR_LIMIT_CPU

      See Also:
        Constant Field Values

    - #### APR_LIMIT_MEM

          public static final int APR_LIMIT_MEM

      See Also:
        Constant Field Values

    - #### APR_LIMIT_NPROC

          public static final int APR_LIMIT_NPROC

      See Also:
        Constant Field Values

    - #### APR_LIMIT_NOFILE

          public static final int APR_LIMIT_NOFILE

      See Also:
        Constant Field Values

    - #### APR_OC_REASON_DEATH

          public static final int APR_OC_REASON_DEATH

      child has died, caller must call unregister still
      See Also:
        Constant Field Values

    - #### APR_OC_REASON_UNWRITABLE

          public static final int APR_OC_REASON_UNWRITABLE

      write_fd is unwritable
      See Also:
        Constant Field Values

    - #### APR_OC_REASON_RESTART

          public static final int APR_OC_REASON_RESTART

      a restart is occurring, perform any necessary cleanup (including sending a special signal to child)
      See Also:
        Constant Field Values

    - #### APR_OC_REASON_UNREGISTER

          public static final int APR_OC_REASON_UNREGISTER

      unregister has been called, do whatever is necessary (including kill the child)
      See Also:
        Constant Field Values

    - #### APR_OC_REASON_LOST

          public static final int APR_OC_REASON_LOST

      somehow the child exited without us knowing ... buggy os?
      See Also:
        Constant Field Values

    - #### APR_OC_REASON_RUNNING

          public static final int APR_OC_REASON_RUNNING

      a health check is occurring, for most maintenance functions this is a no-op.
      See Also:
        Constant Field Values

    - #### APR_KILL_NEVER

          public static final int APR_KILL_NEVER

      process is never sent any signals
      See Also:
        Constant Field Values

    - #### APR_KILL_ALWAYS

          public static final int APR_KILL_ALWAYS

      process is sent SIGKILL on apr_pool_t cleanup
      See Also:
        Constant Field Values

    - #### APR_KILL_AFTER_TIMEOUT

          public static final int APR_KILL_AFTER_TIMEOUT

      SIGTERM, wait 3 seconds, SIGKILL
      See Also:
        Constant Field Values

    - #### APR_JUST_WAIT

          public static final int APR_JUST_WAIT

      wait forever for the process to complete
      See Also:
        Constant Field Values

    - #### APR_KILL_ONLY_ONCE

          public static final int APR_KILL_ONLY_ONCE

      send SIGTERM and then wait
      See Also:
        Constant Field Values

    - #### APR_PROC_DETACH_FOREGROUND

          public static final int APR_PROC_DETACH_FOREGROUND

      See Also:
        Constant Field Values

    - #### APR_PROC_DETACH_DAEMONIZE

          public static final int APR_PROC_DETACH_DAEMONIZE

      Do not detach
      See Also:
        Constant Field Values

    - #### MAX_ARGS_SIZE

          public static final int MAX_ARGS_SIZE

      Detach
      See Also:
        Constant Field Values

    - #### MAX_ENV_SIZE

          public static final int MAX_ENV_SIZE

      See Also:
        Constant Field Values

  - ### Constructor Detail

    - #### Proc

          public Proc()

  - ### Method Detail

    - #### 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 handle
        `progname` - The program to run
        `args` - 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 process
        `pool` - 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 process
        `exit` - 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 information
        `exit` - 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

Copyright © 2000-2020 Apache Software Foundation. All Rights Reserved.