Skip to content
Snippets Groups Projects
Commit fb2a39bd authored by iliya's avatar iliya
Browse files

vsy jsp fml

parent 2c9170a4
No related branches found
No related tags found
No related merge requests found
*.o
child_list
CC := clang
CFLAGS := -g -pedantic -Wall -Wextra -std=c2x
LDFLAGS := -fsanitize=address -fsanitize=leak -fsanitize=undefined -lm
TARGET := child_list
all: $(TARGET)
$(TARGET): child_list.o
@printf "=================== Building executable ===================\n"
$(CC) $(CFLAGS) $^ -o $@ $(LDFLAGS)
@printf "\n"
%.o: %.c
@printf "================== Building object files ==================\n"
$(CC) $(CFLAGS) -c $<
@printf "\n"
.PHONY: clean
clean:
rm -f *.o $(TARGET)
#include <stddef.h>
#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <unistd.h>
#define NB_PROCESSES 10
int main(void) {
pid_t pid = -1;
pid = fork();
if (pid > 0) {
for (int i = 0; i < NB_PROCESSES; i++) {
fork();
}
} else if (pid == 0) {
fprintf(stdout, "Child (%d) \t Parent(%d)\n", getpid(), getppid());
exit(EXIT_SUCCESS);
} else {
perror("fork");
}
return EXIT_SUCCESS;
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment