summaryrefslogtreecommitdiff
path: root/examples/OS
diff options
context:
space:
mode:
authorharrison <harrison@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>1997-05-11 00:38:54 +0000
committerharrison <harrison@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>1997-05-11 00:38:54 +0000
commitbb6763417d6e3373847a62c51d544a791a836e61 (patch)
treecbb9dd953414e056eea8d19211ffd23ea86c8584 /examples/OS
parenta2c8174568894a216de123fdbd03037d9124d3b1 (diff)
downloadATCD-bb6763417d6e3373847a62c51d544a791a836e61.tar.gz
Works with the new ACE_ProcessEx.
Diffstat (limited to 'examples/OS')
-rw-r--r--examples/OS/Process/README41
-rw-r--r--examples/OS/Process/process.cpp34
2 files changed, 27 insertions, 48 deletions
diff --git a/examples/OS/Process/README b/examples/OS/Process/README
index 3a28ed03bd0..2c2c801d5df 100644
--- a/examples/OS/Process/README
+++ b/examples/OS/Process/README
@@ -1,33 +1,10 @@
This example shows how to use ACE_Process to "portably" create new
-processes. The ACE_Process_Options class allows applications to
-portably specify path, command-line arguments, environment variable
-values. It also allows applications to set the new process' standard
-handles (stdin, stdout, and stderr). ACE_Process is created with the
-ACE_Process_Options and can be used to perform operations on the
-running process.
-
-Run the application as ./process -u to get all the command-line
-options.
-
-Here's an example output:
-
-lambada:OS/Process> ./process -a
-starting...
-starting...
-Fri May 9 01:01:06 CDT 1997
-date succeeded.
-total 598
-drwxr-xr-x 5 harrison doc 512 May 9 00:47 .
--rw-r--r-- 1 harrison doc 9330 May 7 23:54 .#process.cpp.4.3
-drwxr-xr-x 4 harrison doc 512 Apr 21 15:32 ..
-drwx------ 2 harrison doc 512 May 8 22:33 .obj
-drwx------ 2 harrison doc 512 May 8 22:33 .shobj
-drwxr-xr-x 2 harrison doc 512 May 8 00:11 CVS
--rw-r--r-- 1 harrison doc 1717 Oct 21 1996 Makefile
--rw-r--r-- 1 harrison doc 10048 Oct 21 1996 Process.mak
--rw-r--r-- 1 harrison doc 44032 Oct 21 1996 Process.mdp
--rw-r--r-- 1 harrison doc 585 Oct 21 1996 README
--rwx--x--x 1 harrison doc 212992 May 9 01:00 process
--rw-r--r-- 1 harrison doc 9960 May 9 01:00 process.cpp
--rw------- 1 harrison doc 1042 May 9 00:47 process.wst
-
+processes and set their standard handles (stdin, stdout, and stderr).
+On UNIX, ACE_Process uses fork and exec. On Win32, it uses
+CreateProcess. Since we can set the standard handles, we can mimic
+UNIX pipes on Win32 by building chains of processes.
+
+Run the application by typing ./process [filename]. It creates a new
+process to print the contents of <filename> (default is the name of
+the file "process.cpp") to the main console. So all you should see is
+process.cpp printed to the screen. Not very exciting...
diff --git a/examples/OS/Process/process.cpp b/examples/OS/Process/process.cpp
index e540906381d..6f85befc6c2 100644
--- a/examples/OS/Process/process.cpp
+++ b/examples/OS/Process/process.cpp
@@ -112,7 +112,7 @@ test_more (void)
ACE_ProcessEx new_process;
ACE_Process_Options options;
- options.path (executable);
+ options.command_line (executable);
options.set_handles (infile);
if (new_process.start (options) == -1)
@@ -133,7 +133,7 @@ static void
test_date (void)
{
ACE_Process_Options options;
- options.path (DATE_PATH);
+ options.command_line (DATE_PATH);
// Try to create a new process running date.
ACE_ProcessEx new_process;
@@ -153,8 +153,7 @@ static void
test_ls (void)
{
ACE_Process_Options options;
- options.path (LS_PATH);
- options.cl_options ("-al");
+ options.command_line ("%s -al", LS_PATH);
ACE_ProcessEx new_process;
if (new_process.start (options) == -1)
@@ -192,13 +191,13 @@ win32_test_ls (void)
TRUE,
DUPLICATE_SAME_ACCESS))
{
- ACE_ERROR ((LM_ERROR, "%p duplicate failed.\n", "test_cp"));
+ ACE_ERROR ((LM_ERROR, "%p duplicate failed.\n", "test_ls"));
return;
}
BOOL fork_result =
- ::CreateProcess (0,
- "c:\\Utils\\bin\\ls.exe -l",
+ ::CreateProcess ("c:\\Utils\\bin\\ls.exe",
+ "-a",
NULL, // No process attributes.
NULL, // No thread attributes.
TRUE, // Allow handle inheritance.
@@ -211,7 +210,7 @@ win32_test_ls (void)
::CloseHandle (startup_info.hStdOutput);
if (fork_result == 0)
- ACE_ERROR ((LM_ERROR, "%p.\n", "test_cp"));
+ ACE_ERROR ((LM_ERROR, "%p CreateProcess failed.\n", "test_ls"));
else
{
::WaitForSingleObject (process_info.hProcess, INFINITE);
@@ -298,7 +297,7 @@ win32_spawn_environment_process (void)
TRUE, // Allow handle inheritance.
NULL, // CREATE_NEW_CONSOLE, // Create a new console window.
environment, // Environment.
- //"d:\\harrison\\ACE_wrappers\\examples\\OS\\Process\\", // Current directory to start in.
+ //"d:\\harrison\\ACE_wrappers\\examples\\OS\\Process\\",
0,
&startup_info,
&process_info);
@@ -320,9 +319,10 @@ static void
test_setenv (const char *argv0)
{
ACE_Process_Options options;
- options.setenv ("ACE_PROCESS_TEST", "here's a really large number: %u", 0 - 1);
- options.path (argv0);
- options.cl_options ("-g");
+ // options.setenv ("ACE_PROCESS_TEST", "here's a really large number: %u", 0 - 1);
+ options.setenv ("ACE_PROCESS_TEST= here's a large number %u", 0 - 1);
+ options.setenv ("ACE_PROCESS_TEST2", "ophilli");
+ options.command_line ("%s -g", argv0);
ACE_ProcessEx process;
if (process.start (options) == -1)
{
@@ -370,8 +370,7 @@ main (int argc, char *argv[])
if (run_all)
{
ACE_Process_Options options;
- options.path (argv[0]);
- options.cl_options ("-d -l -e running");
+ options.command_line ("%s -d -l -s", argv[0]);
ACE_ProcessEx process;
if (process.start (options) == -1)
ACE_ERROR_RETURN ((LM_ERROR, "%p.\n", "main"), -1);
@@ -388,8 +387,11 @@ main (int argc, char *argv[])
{
ACE_DEBUG ((LM_DEBUG, "checking ACE_PROCESS_TEST\n"));
char *value = ACE_OS::getenv ("ACE_PROCESS_TEST");
- ACE_DEBUG ((LM_DEBUG, "ACE_PROCESS_TEST = %s.\n",
- value == 0 ? "no value" : value));
+ char *value2 = ACE_OS::getenv ("ACE_PROCESS_TEST2");
+ ACE_DEBUG ((LM_DEBUG, "ACE_PROCESS_TEST = %s.\n"
+ "ACE_PROCESS_TEST2 = %s.\n",
+ value == 0 ? "no value" : value,
+ value2 == 0 ? "no value" : value2));
}
if (run_ls)