Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
T
tp1-ProgDev-mertens-guilherme
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Mertens De Andrade Guilherme
tp1-ProgDev-mertens-guilherme
Commits
8c28709b
Commit
8c28709b
authored
5 months ago
by
Mertens De Andrade Guilherme
Browse files
Options
Downloads
Patches
Plain Diff
first question
parent
7750eeda
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
server_1.c
+59
-0
59 additions, 0 deletions
server_1.c
with
59 additions
and
0 deletions
server_1.c
0 → 100644
+
59
−
0
View file @
8c28709b
#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:
*/
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment