日期:2014-05-16 浏览次数:20838 次
/**
* @file factorial.cpp
* @brief
*/
#include "ace/OS.h"
#include "ace/ACE.h"
#include "ace/Process.h"
int main(int argc, char *argv[])
{
ACE_Process_Options options;
FILE *fp = NULL;
char *n_env = NULL;
int n;
if (argc == 1) {
// Top-level process.
n_env = ACE_OS::getenv ("FACTORIAL");
n = n_env == 0 ? 0 : atoi (n_env);
options.command_line ("%s %d", argv[0], n == 0 ? 10 : n);
const char *working_dir = ACE_OS::getenv ("WORKING_DIR");
if (working_dir) options.working_directory (working_dir);
fp = fopen ("factorial.log", "a");
options.setenv ("PROGRAM=%s", ACE::basename (argv[0]));
} else {
fp = fopen ("factorial.log", "a");
if (atoi (argv[1]) == 1) {
// Base case
fprintf (fp, "[%s|%d]: base case\n",
ACE_OS::getenv ("PROGRAM"), ACE_OS::getpid ());
fclose (fp);
return 1;
} else {
n = atoi (a