This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
> 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. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
> python fork_zombie.py | |
I created a child and now all I want to do is sleep… | |
Goodbye cruel world! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
> ps -ef | grep 26556 | |
lex 26556 26555 0 21:40 pts/3 00:00:00 [python] <defunct> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
^CTraceback (most recent call last): | |
File "fork.py", line 11, in | |
time.sleep(1) | |
KeyboardInterrupt |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
> ps -e | grep 27439 | |
> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- hosts: all | |
sudo: yes | |
vars: | |
cap_file: packet_capture_{{ ansible_hostname }}_{{ ansible_date_time['epoch'] }}.cap |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
tasks: | |
- name: start tcpdump | |
command: /usr/sbin/tcpdump -i eth0 -s 0 -w /tmp/${cap_file} | |
async: 60 | |
poll: 0 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- pause: minutes=1 prompt="pause for 60 seconds or press Ctrl + c then c to continue" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- name: kill tcpdump | |
command: /usr/bin/pkill tcpdump | |
ignore_errors: yes |