chore: import upstream snapshot with attribution
This commit is contained in:
@@ -0,0 +1,13 @@
|
||||
SRCS = $(wildcard *.c)
|
||||
|
||||
PROGS = $(patsubst %.c,%,$(SRCS))
|
||||
|
||||
all: $(PROGS)
|
||||
|
||||
%: %.c
|
||||
$(CC) $(CFLAGS) -o $@ $<
|
||||
|
||||
clean:
|
||||
rm -f $(PROGS)
|
||||
|
||||
.PHONY: all clean
|
||||
@@ -0,0 +1,12 @@
|
||||
#include <stdio.h>
|
||||
|
||||
// Most of the C compilers support a third parameter to main which
|
||||
// store all envorinment variables
|
||||
int main(int argc, char *argv[], char * envp[])
|
||||
{
|
||||
int i;
|
||||
for (i = 0; envp[i] != NULL; i++)
|
||||
printf("\n%s", envp[i]);
|
||||
getchar();
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
#include <stdio.h>
|
||||
|
||||
int main()
|
||||
{
|
||||
printf("Hello, World!\n");
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
#include <unistd.h>
|
||||
|
||||
int main()
|
||||
{
|
||||
link("env", "env3");
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
#include <fcntl.h>
|
||||
#include <stdio.h>
|
||||
#include <errno.h>
|
||||
|
||||
int main()
|
||||
{
|
||||
int ret = openat(AT_FDCWD, "/dev/tty", 0x88102, 0);
|
||||
printf("return value is %d and errno is %d\n", ret, errno);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
#include <sys/wait.h>
|
||||
#include <unistd.h>
|
||||
#include <errno.h>
|
||||
#include <stdio.h>
|
||||
|
||||
int main()
|
||||
{
|
||||
int status;
|
||||
|
||||
pid_t p = getpid();
|
||||
// waitpid takes a children's pid, not the current process one
|
||||
// if the pid is not a children of the current process, it returns -ECHILD
|
||||
pid_t res = waitpid(1001, &status, WNOHANG);
|
||||
|
||||
printf("res is %d, p is %d and errno is %d\n", res, p, errno);
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user