I have a python script that runs a number of C ++ programs, a command line parameter is passed to each program, as shown below
process_path "~/test/" process_name "test" num_process = 10 for p in range(1, num_processes, 1): subprocess.Popen([process_path + process_name, str(p)], shell = False)
Is it possible to set setproctitle to rename each of these processes so that I can include the command line parameter as part of the process name, if so, how would you do it?
If you pass kwarg executableto subprocess.Popen, you can use the first argument in the argument list:
executable
subprocess.Popen
subprocess.Popen(['some string you choose', str(p)], executable=process_path+process_name, shell=False)
docs say: "On Unix, it becomes the display name for the executable in utilities such as ps."
setproctitle "" , , - - - , .
, setproctitle , , , , , Linux , .
Linux prctl(), , prctl (PR_SET_NAME, "my_new_name" );, . , , setproctitle - .
++, prctl.
Linux, , , , prctl.
Windows: , (, calc.exe). ( , ) (CUI), start ( , start/? ):
for p in range(1, num_processes, 1): subprocess.Popen(['start', str(p), process_path + process_name, str(p)], shell = False) # ^ this is the title
.
Source: https://habr.com/ru/post/1761113/More articles:Working with iPad orientation in javascript - javascriptGet one accelerometer value - androidHow do you format a date range in Java? - javaΠ Π΅ΠΆΠΈΠΌ ΠΎΡΠ»Π°Π΄ΠΊΠΈ ΠΏΡΠΎΡΠΈΠ² ΡΠ΅ΠΆΠΈΠΌΠ° Π²ΡΠΏΡΡΠΊΠ° - ΡΠ²ΠΎΠΉΡΡΠ²ΠΎ IsJITOptimizerDisabled - c#Problems with QScript - c ++Why is my SqlDependency not working - sql-serverProgrammatically send SMS messages using a personal mobile account? - smsTo what extent do you quote the author in the project fork? - javaSqlDependency not working - sqldeploying my first mobile site: 3 questions for newbies - javascriptAll Articles