## NAME

ACE_Process_Options - Process Options

## SYNOPSIS

    #include <ace/Process.h>

    class ACE_Process_Options
    {
      public:
        enum{ DEFAULT_COMMAND_LINE_BUF_LEN = 1024, #if defined (
            ACE_WIN32) NO_EXEC = 0 #else NO_EXEC = 1 #endif };

        ACE_Process_Options (
            int inherit_environment = 1,
            int command_line_buf_len = DEFAULT_COMMAND_LINE_BUF_LEN,
            int env_buf_len = ENVIRONMENT_BUFFER,
            int max_env_args = MAX_ENVIRONMENT_ARGS
            );
        ~ACE_Process_Options (void);
        = These operations are used by applications to portably set int set_handles (
            ACE_HANDLE std_in,
            ACE_HANDLE std_out = ACE_INVALID_HANDLE,
            ACE_HANDLE std_err = ACE_INVALID_HANDLE
            );
        int setenv (LPCTSTR format, ...);
        int setenv (LPCTSTR variable_name, LPCTSTR format, ...);
        int setenv (LPTSTR envp[]);
        void working_directory (LPCTSTR wd);
        int command_line (LPCTSTR format, ...);
        int command_line (LPCTSTR const argv[]);
        u_long creation_flags (void) const;
        void creation_flags (u_long);
        LPTSTR working_directory (void);
        LPTSTR command_line_buf (void);
        LPTSTR env_buf (void);
        STARTUPINFO *startup_info (void);
        LPSECURITY_ATTRIBUTES get_process_attributes (void) const;
        LPSECURITY_ATTRIBUTES set_process_attributes (void);
        LPSECURITY_ATTRIBUTES get_thread_attributes (void) const;
        LPSECURITY_ATTRIBUTES set_thread_attributes (void);
        int handle_inheritence (void);
        void handle_inheritence (int);
        char *const *command_line_argv (void);
        char *const *env_argv (void);
        ACE_HANDLE get_stdin (void);
        ACE_HANDLE get_stdout (void);
        ACE_HANDLE get_stderr (void);
        void avoid_zombies (int);
        int avoid_zombies (void);
      protected:
            enum{ MAX_COMMAND_LINE_OPTIONS = 128,
            ENVIRONMENT_BUFFER = 16 * 1024,
            MAX_ENVIRONMENT_ARGS = 512 };

        int setenv_i (LPTSTR assignment, int len);
        int inherit_environment_;
        u_long creation_flags_;
        void inherit_environment (void);
        int environment_inherited_;
        STARTUPINFO startup_info_;
        BOOL handle_inheritence_;
        LPSECURITY_ATTRIBUTES process_attributes_;
        LPSECURITY_ATTRIBUTES thread_attributes_;
        SECURITY_ATTRIBUTES security_buf1_;
        SECURITY_ATTRIBUTES security_buf2_;
        ACE_HANDLE stdin_;
        ACE_HANDLE stdout_;
        ACE_HANDLE stderr_;
        int avoid_zombies_;
        int set_handles_called_;
        int environment_buf_index_;
        int environment_argv_index_;
        LPTSTR environment_buf_;
        int environment_buf_len_;
        LPTSTR* environment_argv_;
        int max_environment_args_;
        int max_environ_argv_index_;
        TCHAR working_directory_[MAXPATHLEN + 1];
        int command_line_argv_calculated_;
        LPTSTR command_line_buf_;
        LPTSTR command_line_argv_[MAX_COMMAND_LINE_OPTIONS];
    };

## DESCRIPTION

This class controls the options passed to `CreateProcess` (or `fork` and `exec`). Notice that on Windows CE, creating a process merely means instantiating a new process. You can't set the handles (since there's no stdin, stdout and stderr,) specify process/thread options, set environment,... So, basically, this class only set the command line and nothing else.

Notice that on UNIX platforms, if the `setenv` is used, the `spawn` is using the `execve` system call. It means that the `command_line` should include a full path to the program file (`execve` does not search the PATH). If `setenv` is not used then, the `spawn` is using the `execvp` which searches for the program file in the PATH variable.

## Default settings not part of public Interface.

@@ These sizes should be taken from the appropriate POSIX/system header files and/or defined dynamically.

## Non-portable accessors for when you

just have to use them.""

    STARTUPINFO *startup_info (void);

Used for setting and getting.

    LPSECURITY_ATTRIBUTES get_process_attributes (void) const;

Get the process_attributes. Returns NULL if set_process_attributes has not been set.

    LPSECURITY_ATTRIBUTES set_process_attributes (void);

If this is called, a non-null process attributes is sent to CreateProcess.

    LPSECURITY_ATTRIBUTES get_thread_attributes (void) const;

Get the thread_attributes. Returns NULL if set_thread_attributes has not been set.

    LPSECURITY_ATTRIBUTES set_thread_attributes (void);

If this is called, a non-null thread attributes is sent to CreateProcess.

    int handle_inheritence (void);

Default is TRUE.

    void handle_inheritence (int);

Allows disabling of handle inheritence.

    char *const *command_line_argv (void);

argv-style command-line options. Parses and modifies the string created from this-command_line. All spaces not in quotes ("" or '') are replaced with null (\ ) bytes. An argv array is built and returned with each entry pointing to the start of null-terminated string. Returns { 0 } if nothing has been set.

    char *const *env_argv (void);

argv-style array of environment settings.

## Accessors for the standard handles.

    ACE_HANDLE get_stdin (void);

    ACE_HANDLE get_stdout (void);

    ACE_HANDLE get_stderr (void);

    void avoid_zombies (int);

Set value for avoid_zombies.

    int avoid_zombies (void);

Get current value for avoid_zombies.

## AUTHOR

Tim Harrison `harrison@cs.wustl.edu`

## LIBRARY

ace