1

I want to set a name to the child process spawned by subprocess module.

subprocess.Popen(["ls"]) spawns child process named ls, but I want to set a custom name of the process. For example, if I open top instead of process showed by name ls, it will be showed by custom name e.g. list-all-files set by me. How can I do that by using subprocess module or any other way?

user
  • 5,335
  • 7
  • 47
  • 63

1 Answers1

0

How about using a link and aliasing?

user@localhost: ln -s /bin/ls list-all-files
user@localhost: alias ls list-all-files

When you now run subprocess.Popen(['ls']) you'll only see a process list-all-files running in a ps/top.

Otherwise a bash wrapper might be a good way to go.

gnr
  • 2,324
  • 1
  • 22
  • 24