Knowledge

wait (system call)

Source 📝

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

Index


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
Orphan process

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