execve: Use interp in shebang as is
Fujitsu: POSTK_DEBUG_TEMP_FIX_9 Refs: #995 Change-Id: I09751d13c4fecd68087d47815029c0b65e51f18a
This commit is contained in:
committed by
Masamichi Takagi
parent
f1a40a409f
commit
b920da5103
33
test/issues/995/call_execve.c
Normal file
33
test/issues/995/call_execve.c
Normal file
@@ -0,0 +1,33 @@
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
char *command;
|
||||
char *exargv[128] = {};
|
||||
char *exenvp[1] = {NULL};
|
||||
int i, rc;
|
||||
|
||||
if (argc < 2) {
|
||||
printf("Error: too few arguments\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
exargv[0] = argv[1];
|
||||
|
||||
for (i = 2; i < argc; i++) {
|
||||
exargv[i - 1] = argv[i];
|
||||
}
|
||||
exargv[i - 1] = NULL;
|
||||
|
||||
rc = execve(argv[1], exargv, exenvp);
|
||||
|
||||
/* Don't reach here */
|
||||
if (rc == -1) {
|
||||
perror("Error: failed to execve");
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
Reference in New Issue
Block a user