File tree Expand file tree Collapse file tree 1 file changed +8
-7
lines changed Expand file tree Collapse file tree 1 file changed +8
-7
lines changed Original file line number Diff line number Diff line change @@ -43,6 +43,8 @@ int execute_cmd(char *jname, char **argv)
43
43
int home_set = 0 , jexec_index = 0 , freebsd_ver = 0 ;
44
44
FILE * fp ;
45
45
char buffer [128 ];
46
+ int status = 0 ;
47
+ int errcode = 0 ;
46
48
47
49
if (!workdir ) {
48
50
fprintf (stderr , "Environment variable 'workdir' is not set.\n" );
@@ -143,28 +145,27 @@ int execute_cmd(char *jname, char **argv)
143
145
// fprintf(stderr, "No command specified.\n");
144
146
// exit(1);
145
147
// }
146
-
147
148
// Execute the command with the new environment
148
149
execv ("/usr/sbin/jexec" , jexec_argv );
149
150
// If execv returns, it failed
150
151
perror ("execv failed" );
151
152
exit (1 );
152
153
} else if (pid > 0 ) {
153
- wait (NULL );
154
+ waitpid (pid , & status , 0 );
155
+ errcode = WEXITSTATUS (status );
154
156
} else {
155
157
perror ("fork failed" );
156
158
exit (1 );
157
159
}
158
160
159
- return 0 ;
161
+ return errcode ;
160
162
}
161
163
162
164
int main (int argc , char * * argv )
163
165
{
166
+ int errcode = 0 ;
164
167
char * jname = NULL ;
165
-
166
168
jname = argv [1 ];
167
-
168
- execute_cmd (jname , argv );
169
- return 0 ;
169
+ errcode = execute_cmd (jname , argv );
170
+ exit (errcode );
170
171
}
You can’t perform that action at this time.
0 commit comments