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); 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); pid_t getgroup (void) const; pid_t setgroup (pid_t pgrp); 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]; pid_t process_group_; };

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.

Methods to set process creation options portably.

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);

= ACE_Process uses these operations to retrieve option values.

LPTSTR working_directory (void);

LPTSTR command_line_buf (void);

LPTSTR env_buf (void);

Get/set process group.

pid_t getgroup (void) const;

pid_t setgroup (pid_t pgrp);

Non-portable accessors for when you

just have to use them.""
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);

Accessors for the standard handles.

ACE_HANDLE get_stdin (void);

ACE_HANDLE get_stdout (void);

ACE_HANDLE get_stderr (void);

void avoid_zombies (int);

int avoid_zombies (void);

AUTHOR

Tim Harrison harrison@cs.wustl.edu

LIBRARY

ace