Skip to content

Instantly share code, notes, and snippets.

View lextoumbourou's full-sized avatar

Lex Toumbourou lextoumbourou

View GitHub Profile
> python fork_wait.py
Hope my parent doesn't forget me this time!
Right now, my parent is 20037
Right now, my parent is 20037
Right now, my parent is 20037
My child has finished processing. My work here is done.
from os import fork, getppid, wait
from sys import exit
from time import sleep
pid = fork()
if pid == 0:
exit("Goodbye, cruel world")
else:
print "I created a child:", pid
> python fork_zombie.py
I created a child and now all I want to do is sleep…
Goodbye cruel world!
> ps -ef | grep 26556
lex 26556 26555 0 21:40 pts/3 00:00:00 [python] <defunct>
^CTraceback (most recent call last):
File "fork.py", line 11, in
time.sleep(1)
KeyboardInterrupt
- hosts: all
sudo: yes
vars:
cap_file: packet_capture_{{ ansible_hostname }}_{{ ansible_date_time['epoch'] }}.cap
tasks:
- name: start tcpdump
command: /usr/sbin/tcpdump -i eth0 -s 0 -w /tmp/${cap_file}
async: 60
poll: 0
- pause: minutes=1 prompt="pause for 60 seconds or press Ctrl + c then c to continue"
- name: kill tcpdump
command: /usr/bin/pkill tcpdump
ignore_errors: yes