/* * "THE CHEESE-WARE LICENSE" (Revision 1): * wrote this file. As long as you retain this notice * you can do whatever you want with this stuff. If we meet some day, * and you think this stuff is worth it, you can buy me some cheese * in return */ #include #include #include #include "common.h" #define PROG_PREFIX "son: " #define log(fmt, args...) printf(PROG_PREFIX fmt "\n", ##args) int main(int argc, const char **argv) { log("\n" "HEEEEEY, father\n" "There's an endless road to rediscover\n" "HEEEEEY, sister\n" "Do you still belive in love I wonder"); if (argc != 2) { log("Ooops, wrong amount of args, %d", argc); return EXIT_FAILURE; } long mode = strtol(argv[1], NULL, 10); log("mode: %ld", mode); switch(mode) { case WAIT_FOR_CHILD: log("pid %d ppid %d", getpid(), getppid()); sleep(5); break; case DONT_WAIT_FOR_CHILD: log("before parent die: pid %d ppid %d", getpid(), getppid()); sleep(5); log("after parent die: pid %d ppid %d", getpid(), getppid()); break; case ZOMBIE_PROCESS: break; default: return EXIT_FAILURE; } return EXIT_SUCCESS; }