Skip to main content

Posts

Showing posts from June, 2013

Sending a SIGHUP signal to some external process from Python script

Code : import psutil import os import signal pids = psutil.get_pid_list() for pid in pids: if psutil.Process(pid).name == "process_name": os.kill(pid,signal.SIGHUP) break Steps to follow. 1.Get the PID of the process, in this case  "process_name"   to which you want to send out a SIGHUP signal. 2.Use os.kill(pid,sig) command to send out the SIGHUP signal to that process. 1.Get the PID of the process to which you want to send out a SIGHUP signal. One has to install a package called psutil by the following command. easy_install psutil Check out the following links for more details https://code.google.com/p/psutil/ https://pypi.python.org/pypi/psutil use psutil.get_pid_list() to get all of the PIDs. psutil.get_pid_list() works in the following manner.  pids = [ int ( x ) for x in os . listdir ( '/proc' ) if x . isdigit ()] return pids once you get all the PIDs get the PID you are i

error: command 'gcc' failed with exit status 1 while installing eventlet[Solved] for centos or ubuntu

Solution : Install python-devel using following command. yum install python-devel FYI, OS I was running. # uname -a Linux Dell620 2.6.32-220.17.1.el6.x86_64 #1 SMP Wed May 16 00:01:37 BST 2012 x86_64 x86_64 x86_64 GNU/Linux # cat /etc/redhat-release   CentOS release 6.2 (Final) for Ubuntu use the following command  aptitude install python-dev

How to debug a deadlock in multithreaded c/c++ program

Debugging a deadlock in multithreaded program can be little tricky . So the rescuer GDB is there for the help.I am just giving here the head start one needs to debug a multithreaded program for deadlocks. Run your program in GDB, wait until the deadlock happens and then use the following commands. 1. info threads which will list all of the threads that are running and a little * on the one which is currently running. Sample output  5 Thread 0x7ffff6be3700 (LWP 20175) 0x00000032cf6de8b3 in select () from /lib64/libc.so.6 3 Thread 0x7ffff75e4700 (LWP 20173) 0x00000032cf6ab15d in nanosleep () from /lib64/libc.so.6 2 Thread 0x7ffff7fe5700 (LWP 20172) 0x00000032cf6cd177 in sched_yield () from /lib64/libc.so.6 * 1 Thread 0x7ffff7fe7720 (LWP 20168) 0x00000032cf6de8b3 in select () from /lib64/libc.so.6 So one can see where all the threads are waiting at this point, so if happens to be a dead lock, threads must be stuck on lock or unlock. to see whats the thread name and all one c