summaryrefslogtreecommitdiff
path: root/pypers/marelli/modulo4/test_parent_child
diff options
context:
space:
mode:
Diffstat (limited to 'pypers/marelli/modulo4/test_parent_child')
-rwxr-xr-xpypers/marelli/modulo4/test_parent_child/child.py4
-rwxr-xr-xpypers/marelli/modulo4/test_parent_child/parent.py9
-rwxr-xr-xpypers/marelli/modulo4/test_parent_child/test_kill_parent.sh7
3 files changed, 20 insertions, 0 deletions
diff --git a/pypers/marelli/modulo4/test_parent_child/child.py b/pypers/marelli/modulo4/test_parent_child/child.py
new file mode 100755
index 0000000..098ed4b
--- /dev/null
+++ b/pypers/marelli/modulo4/test_parent_child/child.py
@@ -0,0 +1,4 @@
+import time
+for i in range(10):
+ print "%s I am the child!" % i
+ time.sleep(1)
diff --git a/pypers/marelli/modulo4/test_parent_child/parent.py b/pypers/marelli/modulo4/test_parent_child/parent.py
new file mode 100755
index 0000000..0dcc172
--- /dev/null
+++ b/pypers/marelli/modulo4/test_parent_child/parent.py
@@ -0,0 +1,9 @@
+from subprocess import Popen
+from time import sleep
+from os import getpid
+
+print >> file("parent.pid", "w"), getpid()
+child = Popen(["python", "child.py"])
+print "Parent id: %s" % getpid()
+print "Child id: %s" % child.pid
+sleep(60)
diff --git a/pypers/marelli/modulo4/test_parent_child/test_kill_parent.sh b/pypers/marelli/modulo4/test_parent_child/test_kill_parent.sh
new file mode 100755
index 0000000..4d026a4
--- /dev/null
+++ b/pypers/marelli/modulo4/test_parent_child/test_kill_parent.sh
@@ -0,0 +1,7 @@
+#!/bin/bash
+# test that killing the parent does NOT kill the child
+python parent.py&
+sleep 3
+kill `cat parent.pid`
+sleep 1
+ps aux | grep python