I'm running commands from python via popen. On multi-core system, I have a function that will return the string "/usr/bin/taskset -c <>" based on the system's utilization. I then append the string to the system command prior to sending it to popen.
From my observation, the taskset wrapper is functioning correctly, the system command is being observed wrapped in a taskset command from "ps -elf"
4 S root 18986 18978 0 80 0 - 15016 poll_s 10:54 pts/3 00:00:00 sudo /usr/bin/taskset -c 0?sudo /usr/sbin/tcpdump -s 0 -nei lo
I'm not sure what the "?" means, I don't observed that while executing the command manually from linux console
I'm issuing the command via popen
I have a function that decides whether the system is multi-core or not, if its multicore, it will return the string "sudo /usr/bin/taskset -c"
if multicore():
taskstring="sudo /usr/bin/taskset -c %s" % cpu
else:
taskstring=""
The susbsequent command is tpcdump, so it will be
command = taskstring+" sudo /usr/sbin/tcpdump -s 0 -nei lo"
cmd=command.split(" ")
subprocess.Popen(cmd,stdout=open('%s' % fileout,'w'),stderr=subprocess.STDOUT)
I'm running on Ubuntu 14.04, if that means anything....