Skip to content
Snippets Groups Projects
Commit 8c28709b authored by Mertens De Andrade Guilherme's avatar Mertens De Andrade Guilherme
Browse files

first question

parent 7750eeda
No related branches found
No related tags found
No related merge requests found
#include <iostream>
#include <unistd.h>
int main(){
std::cout << "started" << std::endl;
while(1){
std::cout << "id: " << getpid() << std::endl;
std::cout << "father id: " << getppid() << std::endl;
std::cout << "groupd id: " << getpgrp() << std::endl;
std::cout << rand() % 100 << std::endl;
sleep(1);
}
std::cout << "finished" << std::endl;
return EXIT_SUCCESS;
}
/*
PPID PID PGID SID TTY TPGID STAT UID TIME COMMAND
2344 4093 4093 4093 pts/0 4191 Ss 911 0:00 /bin/zsh -i
4093 4191 4191 4093 pts/0 4191 S+ 911 0:00 ./a.out
2344 4219 4219 4219 pts/1 4304 Ss 911 0:00 /bin/zsh -i
4219 4304 4304 4219 pts/1 4304 R+ 911 0:00 ps aj
output from the first terminal:
id: 4191
father id: 4093
groupd id: 4191
84
4191 (group 4191)-> 4093 (group 4093) -> 2344
after finishing the program in the first terminal:
PPID PID PGID SID TTY TPGID STAT UID TIME COMMAND
2344 4093 4093 4093 pts/0 4093 Ss+ 911 0:00 /bin/zsh -i
2344 4219 4219 4219 pts/1 5852 Ss 911 0:00 /bin/zsh -i
4219 5852 5852 4219 pts/1 5852 R+ 911 0:00 ps aj
after relacing the program:
2344 4093 4093 4093 pts/0 6024 Ss 911 0:00 /bin/zsh -i
2344 4219 4219 4219 pts/1 6053 Ss 911 0:00 /bin/zsh -i
4093 6024 6024 4093 pts/0 6024 S+ 911 0:00 ./a.out
4219 6053 6053 4219 pts/1 6053 R+ 911 0:00 ps aj
after killing it: (kill 6024)
output in the first terminal:
id: 6024
father id: 4093
groupd id: 6024
73
[1] 6024 terminated ./a.out
~/workspace:
*/
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment