56{
57
58 printf("RFProcessManager : Execute : scr=%s, nargs=%d\n", scr, nargs);
59
60 pid_t pid = fork();
61 if (pid == (pid_t) 0) {
62 char argbuf[10][256];
63 char* argval[10];
64 int nargval = 0;
66 strcpy(argbuf[0], scr);
67 argval[nargval++] = argbuf[0];
68
69 for (int i = 0; i < nargs; i++) {
70 strcpy(argbuf[nargval], args[i]);
71 argval[nargval] = argbuf[nargval];
72 nargval++;
73
74 }
75 argval[nargval] = NULL;
76
77
78 close(1);
79 dup2(m_iopipe[1], 1);
80 close(2);
81 dup2(m_iopipe[1], 2);
82 close(m_iopipe[0]);
83
84
85 printf("RFProcessManager : invoking %s\n", scr);
86 for (int i = 0; i < 10; i++) {
87 if (argval[i] == NULL) break;
88 printf("argval[%d] = %s\n", i, argval[i]);
89 }
90 fflush(stdout);
91 fflush(stderr);
92 execvp(scr, argval);
93 perror("execvp!!");
94 fprintf(stderr, "missing file : %s\n", scr);
95 fflush(stderr);
96 exit(-1);
97 }
98
99 printf("RFProcessManager : forked. pid=%d\n", pid);
100
101
102 m_pidlist.push_back(pid);
103 return pid;
104}