diff uprogs/zombie.c @ 0:c450faca55f4

Init
author Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
date Sun, 22 Oct 2017 18:25:39 +0900
parents
children
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/uprogs/zombie.c	Sun Oct 22 18:25:39 2017 +0900
@@ -0,0 +1,18 @@
+// Create a zombie process that 
+// must be reparented at exit.
+
+#include "types.h"
+#include "stat.h"
+#include "user.h"
+
+int
+main(void)
+{
+  if(fork() > 0){
+    sleep(5);  // Let child exit before parent.
+    printf(2, "Parent exits!\n");
+    exit();
+  }
+  printf(2, "Child exits!\n");
+  exit();
+}