Skip to contentSkip to conversation

Getting pid of exec'd process

DISCUSSION Prasanta Sadhukhan 3 participants 3 messages Mar 22, 2007

lore
Share & tools
lore
#0 lore raw

Hi,

Can anyone suggest as to how can I get the pid of the process which I have done execv()?
ie, if I do execv(path, cmd) a new process will be launched and now how can I get the pid of this new process?

Regard
Prasanta

#1 lore raw

Hi,

If you are doing execv after creating a child process using fork, then return value of fork will give you the pid of the process.

If you haven't done any fork, then the pid is same the calling process (execv doesn't create any new process, it overwrites the process image of calling one) and can be obtained using the getpid() system call.

Regards,
Cyon P.J.

-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of Prasanta Sadhukhan
Sent: Thursday, March 22, 2007 4:42 PM
To: [email protected]
Subject: Getting pid of exec'd process

Hi,

Can anyone suggest as to how can I get the pid of the process which I have done execv()?
ie, if I do execv(path, cmd) a new process will be launched and now how can I get the pid of this new process?

Regard
Prasanta

-
To unsubscribe from this list: send the line "unsubscribe linux-c-programming" in the body of a message to [email protected] More majordomo info at
http://vger.kernel.org/majordomo-info.html

#2 lore raw
In reply to Prasanta Sadhukhan

hello Prasanta, maybe you can look at
http://patatra.mine.nu/cash/cash.tar.gz

it contains a shell of 160 line of code that uses fork() and execvp() maybe the source code can help you to learn.
Hope this helps.
+ Ben

Quoted 7 lines · Prasanta Sadhukhan

Hi,

Can anyone suggest as to how can I get the pid of the process which I have done execv()?
ie, if I do execv(path, cmd) a new process will be launched and now how can I get the pid of this new process?

Quoted 7 lines

Regard
Prasanta

-
To unsubscribe from this list: send the line "unsubscribe linux-c-programming" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

-
To unsubscribe from this list: send the line "unsubscribe linux-c-programming" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html