How would I go about printing a process id before the process is actually executed? Is there a way I can get the previously executed process id and just increment?
i.e.
printf(<process id>);
execvp(process->args[0], process->args);
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
exec family of syscalls preserve current PID, so just do:
New PIDs are allocated on fork(2), which returns 0 to child process and child process’ PID to parent.