Executing a process by filename and forcing PID

Hi! I'm writing a program that will basically execute a program, and then kill it later upon the users request.

The one problem is that there will be multiple binaries with the same name being ran by this program at once, so when the user decides to kill one of them, I need to know which instance they are requesting to kill, so I may kill that precise one and not any others.

But, I'm at a loss here. I haven't the slightest idea of how to do this, and all my googling has only revealed to me the fork() function, which presumably spawns a child, but the child is the same program as the parent, so you have no control over what the child is. (From what I've read.)

So, please help me or at least guide me in the right direction!

Thanks!

Fud-Lite


Also look up the exec*() family of functions.

The typical paradigm in Un*x is fork() then exec() in the child process.

Fork returns the pid of the new process created.

When you execute the new child process you can store it's pid in a list and then you can kill the correct process with pid rather than binary name.
Topic archived. No new replies allowed.