Initial commit
This commit is contained in:
commit
7ed3ffc7ea
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
|
@ -0,0 +1 @@
|
||||||
|
build/
|
25
Makefile
Normal file
25
Makefile
Normal file
|
@ -0,0 +1,25 @@
|
||||||
|
.PHONY: all
|
||||||
|
all: build/parent-null build/parent-ptr build/child
|
||||||
|
|
||||||
|
build:
|
||||||
|
@mkdir -p build
|
||||||
|
|
||||||
|
build/parent-null: build
|
||||||
|
$(CC) -o build/parent-null src/parent.c
|
||||||
|
|
||||||
|
build/parent-ptr: build
|
||||||
|
$(CC) -o build/parent-ptr -DPTR_TO_NULL src/parent.c
|
||||||
|
|
||||||
|
build/child: build
|
||||||
|
$(CC) -o build/child src/child.c
|
||||||
|
|
||||||
|
.PHONY: test
|
||||||
|
test: all
|
||||||
|
@echo "==> Testing execve with { NULL }..."
|
||||||
|
./build/parent-ptr ./build/child
|
||||||
|
@echo "==> Testing execve with NULL..."
|
||||||
|
./build/parent-null ./build/child
|
||||||
|
|
||||||
|
.PHONY: clean
|
||||||
|
clean:
|
||||||
|
@rm -fr build
|
8
README.md
Normal file
8
README.md
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
# argv0-test
|
||||||
|
|
||||||
|
Simple tester for weird execve calls.
|
||||||
|
|
||||||
|
## How to use
|
||||||
|
```
|
||||||
|
$ make test
|
||||||
|
```
|
7
src/child.c
Normal file
7
src/child.c
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
int
|
||||||
|
main(int argc, char *argv[]) {
|
||||||
|
printf("childproc: argc == %d!\n", argc);
|
||||||
|
return 0;
|
||||||
|
}
|
20
src/parent.c
Normal file
20
src/parent.c
Normal file
|
@ -0,0 +1,20 @@
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
|
int
|
||||||
|
main(int argc, char **argv, char **envp)
|
||||||
|
{
|
||||||
|
char *arr = NULL;
|
||||||
|
char **ptr =
|
||||||
|
#ifdef PTR_TO_NULL
|
||||||
|
&arr;
|
||||||
|
printf("%s: using &NULL as argv...\n", argv[0]);
|
||||||
|
#else
|
||||||
|
NULL;
|
||||||
|
printf("%s: using just NULL as argv...\n", argv[0]);
|
||||||
|
#endif
|
||||||
|
printf("%s: argv == %p\n", argv[0], ptr);
|
||||||
|
execve(argv[1], ptr, envp);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
Loading…
Reference in a new issue