Knowledge

wait (system call)

Source 📝

36: 281:. Such situations are typically handled with a special "root" (or "init") process, which is assigned as the new parent of a process when its parent process exits. This special process detects when an orphan process terminates and then retrieves its exit status, allowing the system to deallocate the terminated child process. 284:
If a child process receives a signal, a waiting parent will then continue execution leaving an orphan process behind. Hence it is sometimes needed to check the argument set by wait, waitpid or waitid and, in the case that WIFSIGNALED is true, wait for the child process again to deallocate resources.
267:
even though it is no longer an actively executing program. Under normal operation it will typically be immediately waited on by its parent, and then reaped by the system, reclaiming the resource (the process table entry). If a child is not waited on by its parent, it continues to consume this
218:. For normal termination, this status also includes the exit code (usually an integer value) that the process returned to the system. During the first 20 years of UNIX, only the low 8 bits of the exit code have been available to the waiting parent. In 1989 with 272:. Such situations are typically handled with a special "reaper" process that locates zombies and retrieves their exit status, allowing the operating system to then deallocate their resources. 207:) to the parent process when a child process terminates, notifying the parent process and allowing it to retrieve the child process's exit status. 178: 17: 166:, which suspends the execution of the parent process while the child executes. When the child process terminates, it returns an 100: 72: 170:
to the operating system, which is then returned to the waiting parent process. The parent process then resumes execution.
53: 79: 119: 86: 57: 68: 360: 365: 46: 93: 370: 214:
returned by a child process typically indicates whether the process terminated normally or
8: 140: 299: 294: 200: 193: 189: 174: 275:
Conversely, a child process whose parent process terminates before it does becomes an
304: 329: 144: 136: 219: 309: 277: 258: 251: 247: 152: 354: 269: 264: 156: 215: 173:
Modern operating systems also provide system calls that allow a process's
211: 167: 163: 192:, or to wait for a single specific child process (identified by its 188:
call that allow a process to wait for any of its child processes to
35: 133: 151:
for another process to complete its execution. In most systems, a
204: 238:. Waitid is a mandatory part of the POSIX standard since 2001. 177:
to create other threads and wait for them to terminate ("
226:has been introduced that returns all bits from the 60:. Unsourced material may be challenged and removed. 184:An operating system may provide variations of the 263:and continues to exist as an entry in the system 352: 256:When a child process terminates, it becomes a 120:Learn how and when to remove this message 14: 353: 241: 159:. The parent process may then issue a 155:can create an independently executing 268:resource indefinitely, and thus is a 58:adding citations to reliable sources 29: 24: 25: 382: 34: 199:Some operating systems issue a 45:needs additional citations for 322: 181:" them) in a similar fashion. 13: 1: 315: 7: 288: 230:call in a structure called 10: 387: 245: 234:in the structure member 330:"Wait System Call in C" 69:"Wait" system call 18:Wait (operating system) 54:improve this article 361:Process (computing) 242:Zombies and orphans 300:fork (system call) 295:exit (system call) 305:Spawn (computing) 137:operating systems 130: 129: 122: 104: 16:(Redirected from 378: 345: 344: 342: 341: 326: 125: 118: 114: 111: 105: 103: 62: 38: 30: 21: 386: 385: 381: 380: 379: 377: 376: 375: 366:C POSIX library 351: 350: 349: 348: 339: 337: 328: 327: 323: 318: 291: 254: 244: 126: 115: 109: 106: 63: 61: 51: 39: 28: 23: 22: 15: 12: 11: 5: 384: 374: 373: 368: 363: 347: 346: 320: 319: 317: 314: 313: 312: 310:Wait (command) 307: 302: 297: 290: 287: 278:orphan process 259:zombie process 252:Orphan process 248:Zombie process 243: 240: 153:parent process 128: 127: 42: 40: 33: 26: 9: 6: 4: 3: 2: 383: 372: 369: 367: 364: 362: 359: 358: 356: 335: 334:GeeksforGeeks 331: 325: 321: 311: 308: 306: 303: 301: 298: 296: 293: 292: 286: 282: 280: 279: 273: 271: 270:resource leak 266: 265:process table 262: 260: 253: 249: 239: 237: 233: 229: 225: 222:, a new call 221: 217: 213: 208: 206: 202: 197: 195: 191: 187: 182: 180: 176: 171: 169: 165: 162: 158: 157:child process 154: 150: 146: 142: 138: 135: 124: 121: 113: 102: 99: 95: 92: 88: 85: 81: 78: 74: 71: –  70: 66: 65:Find sources: 59: 55: 49: 48: 43:This article 41: 37: 32: 31: 19: 371:System calls 338:. Retrieved 336:. 2017-06-03 333: 324: 283: 276: 274: 257: 255: 235: 231: 227: 223: 209: 198: 185: 183: 172: 160: 148: 131: 116: 107: 97: 90: 83: 76: 64: 52:Please help 47:verification 44: 212:exit status 196:) to exit. 168:exit status 164:system call 27:System call 355:Categories 340:2023-05-15 316:References 246:See also: 216:abnormally 194:process ID 110:March 2007 80:newspapers 236:si_status 232:siginfo_t 289:See also 134:computer 205:SIGCHLD 141:process 94:scholar 224:waitid 201:signal 175:thread 147:) may 96:  89:  82:  75:  67:  101:JSTOR 87:books 250:and 228:exit 220:SVR4 210:The 190:exit 186:wait 179:join 161:wait 149:wait 145:task 143:(or 139:, a 73:news 132:In 56:by 357:: 332:. 343:. 261:, 203:( 123:) 117:( 112:) 108:( 98:· 91:· 84:· 77:· 50:. 20:)

Index

Wait (operating system)

verification
improve this article
adding citations to reliable sources
"Wait" system call
news
newspapers
books
scholar
JSTOR
Learn how and when to remove this message
computer
operating systems
process
task
parent process
child process
system call
exit status
thread
join
exit
process ID
signal
SIGCHLD
exit status
abnormally
SVR4
Zombie process

Text is available under the Creative Commons Attribution-ShareAlike License. Additional terms may apply.