#!/usr/bin/env python # -*- mode: python; -*- import Queue, time, signal, os, sys q = Queue.PriorityQueue() n = 0 def sighandler(signum, frame): global q,n n = n + 1 q.put((1,n)) print q.get() signal.signal(signal.SIGINT, sighandler) print 'This is process ' + str(os.getpid()) while 'q' not in raw_input(): print "Still alive"