#!/usr/bin/env python
# (c) Jan Dlabal, 2009.
# This script is provided under the GPLv3 License
# It does nothing else than die when a specified PID dies.
# Useful if you forgot to add ;poweroff after a long-during command you don't want to stop now :)

from os import system
from time import sleep

not_dead = True

pid = input("PID : ")

while not_dead:
	system("ps -e | grep "+repr(pid)+" > tmp.txt")
	f = open("tmp.txt","r")
	str = f.readline()
	if str.find(repr(pid))==-1:
		not_dead = False
	f.close()
	sleep(1)
