Compare commits

...

2 commits

Author SHA1 Message Date
snow flurry 34b099fc33 Makefile: better representation of pointer 2022-01-26 12:51:33 -08:00
snow flurry c9151e7772 parent: cry if execve returns 2022-01-26 12:51:11 -08:00
2 changed files with 5 additions and 2 deletions

View file

@ -15,7 +15,7 @@ build/child: build
.PHONY: test
test: all
@echo "==> Testing execve with { NULL }..."
@echo "==> Testing execve with &NULL..."
./build/parent-ptr ./build/child
@echo "==> Testing execve with NULL..."
./build/parent-null ./build/child

View file

@ -1,9 +1,11 @@
#include <stdio.h>
#include <unistd.h>
#include <string.h>
int
main(int argc, char **argv, char **envp)
{
int ret = 0;
char *arr = NULL;
char **ptr =
#ifdef PTR_TO_NULL
@ -14,7 +16,8 @@ main(int argc, char **argv, char **envp)
printf("%s: using just NULL as argv...\n", argv[0]);
#endif
printf("%s: argv == %p\n", argv[0], ptr);
execve(argv[1], ptr, envp);
ret = execve(argv[1], ptr, envp);
printf("%s: execve failed ;_; got %s\n", argv[0], strerror(ret));
return 0;
}