Previously I would do shlex.split(cmdline[0]) if the cmdline had only one argument. This would break single argument processes with spaces in the executable path.
Now I check both that the cmdline has one argument and that that argument is an executable (using shutil.which()).
This means now it will only fail for relative executable paths with spaces in them, which should be very uncommon.
Previously I would do
shlex.split(cmdline[0])
if the cmdline had only one argument. This would break single argument processes with spaces in the executable path.Now I check both that the cmdline has one argument and that that argument is an executable (using
shutil.which()
).This means now it will only fail for relative executable paths with spaces in them, which should be very uncommon.