root/kernel/exit.c

/* [previous][next][first][last][top][bottom][index][help] */

DEFINITIONS

This source file includes following definitions.
  1. generate
  2. send_sig
  3. notify_parent
  4. release
  5. bad_task_ptr
  6. audit_ptree
  7. session_of_pgrp
  8. kill_pg
  9. kill_sl
  10. kill_proc
  11. sys_kill
  12. is_orphaned_pgrp
  13. has_stopped_jobs
  14. forget_original_parent
  15. __exit_files
  16. exit_files
  17. __exit_fs
  18. exit_fs
  19. __exit_sighand
  20. exit_sighand
  21. exit_mm
  22. exit_notify
  23. do_exit
  24. sys_exit
  25. sys_wait4
  26. sys_waitpid

   1 /*
   2  *  linux/kernel/exit.c
   3  *
   4  *  Copyright (C) 1991, 1992  Linus Torvalds
   5  */
   6 
   7 #undef DEBUG_PROC_TREE
   8 
   9 #include <linux/wait.h>
  10 #include <linux/errno.h>
  11 #include <linux/signal.h>
  12 #include <linux/sched.h>
  13 #include <linux/kernel.h>
  14 #include <linux/resource.h>
  15 #include <linux/mm.h>
  16 #include <linux/tty.h>
  17 #include <linux/malloc.h>
  18 
  19 #include <asm/segment.h>
  20 extern void sem_exit (void);
  21 extern void acct_process (long exitcode);
  22 extern void kerneld_exit(void);
  23 
  24 int getrusage(struct task_struct *, int, struct rusage *);
  25 
  26 static int generate(unsigned long sig, struct task_struct * p)
     /* [previous][next][first][last][top][bottom][index][help] */
  27 {
  28         unsigned long mask = 1 << (sig-1);
  29         struct sigaction * sa = sig + p->sig->action - 1;
  30 
  31         /* always generate signals for traced processes ??? */
  32         if (!(p->flags & PF_PTRACED)) {
  33                 /* don't bother with ignored signals (but SIGCHLD is special) */
  34                 if (sa->sa_handler == SIG_IGN && sig != SIGCHLD)
  35                         return 0;
  36                 /* some signals are ignored by default.. (but SIGCONT already did its deed) */
  37                 if ((sa->sa_handler == SIG_DFL) &&
  38                     (sig == SIGCONT || sig == SIGCHLD || sig == SIGWINCH || sig == SIGURG))
  39                         return 0;
  40         }
  41         p->signal |= mask;
  42         if (p->state == TASK_INTERRUPTIBLE && (p->signal & ~p->blocked))
  43                 wake_up_process(p);
  44         return 1;
  45 }
  46 
  47 int send_sig(unsigned long sig,struct task_struct * p,int priv)
     /* [previous][next][first][last][top][bottom][index][help] */
  48 {
  49         if (!p || sig > 32)
  50                 return -EINVAL;
  51         if (!priv && ((sig != SIGCONT) || (current->session != p->session)) &&
  52             (current->euid ^ p->euid) && (current->euid ^ p->uid) &&
  53             (current->uid ^ p->euid) && (current->uid ^ p->uid) &&
  54             !suser())
  55                 return -EPERM;
  56         if (!sig)
  57                 return 0;
  58         /*
  59          * Forget it if the process is already zombie'd.
  60          */
  61         if (!p->sig)
  62                 return 0;
  63         if ((sig == SIGKILL) || (sig == SIGCONT)) {
  64                 if (p->state == TASK_STOPPED)
  65                         wake_up_process(p);
  66                 p->exit_code = 0;
  67                 p->signal &= ~( (1<<(SIGSTOP-1)) | (1<<(SIGTSTP-1)) |
  68                                 (1<<(SIGTTIN-1)) | (1<<(SIGTTOU-1)) );
  69         }
  70         if (sig == SIGSTOP || sig == SIGTSTP || sig == SIGTTIN || sig == SIGTTOU)
  71                 p->signal &= ~(1<<(SIGCONT-1));
  72         /* Actually generate the signal */
  73         generate(sig,p);
  74         return 0;
  75 }
  76 
  77 void notify_parent(struct task_struct * tsk)
     /* [previous][next][first][last][top][bottom][index][help] */
  78 {
  79         if (tsk->p_pptr == task[smp_num_cpus])          /* Init */
  80                 tsk->exit_signal = SIGCHLD;
  81         send_sig(tsk->exit_signal, tsk->p_pptr, 1);
  82         wake_up_interruptible(&tsk->p_pptr->wait_chldexit);
  83 }
  84 
  85 void release(struct task_struct * p)
     /* [previous][next][first][last][top][bottom][index][help] */
  86 {
  87         int i;
  88 
  89         if (!p)
  90                 return;
  91         if (p == current) {
  92                 printk("task releasing itself\n");
  93                 return;
  94         }
  95         for (i=1 ; i<NR_TASKS ; i++)
  96                 if (task[i] == p) {
  97                         nr_tasks--;
  98                         task[i] = NULL;
  99                         REMOVE_LINKS(p);
 100                         release_thread(p);
 101                         if (STACK_MAGIC != *(unsigned long *)p->kernel_stack_page)
 102                                 printk(KERN_ALERT "release: %s kernel stack corruption. Aiee\n", p->comm);
 103                         free_kernel_stack(p->kernel_stack_page);
 104                         current->cmin_flt += p->min_flt + p->cmin_flt;
 105                         current->cmaj_flt += p->maj_flt + p->cmaj_flt;
 106                         current->cnswap += p->nswap + p->cnswap;
 107                         kfree(p);
 108                         return;
 109                 }
 110         panic("trying to release non-existent task");
 111 }
 112 
 113 #ifdef DEBUG_PROC_TREE
 114 /*
 115  * Check to see if a task_struct pointer is present in the task[] array
 116  * Return 0 if found, and 1 if not found.
 117  */
 118 int bad_task_ptr(struct task_struct *p)
     /* [previous][next][first][last][top][bottom][index][help] */
 119 {
 120         int     i;
 121 
 122         if (!p)
 123                 return 0;
 124         for (i=0 ; i<NR_TASKS ; i++)
 125                 if (task[i] == p)
 126                         return 0;
 127         return 1;
 128 }
 129         
 130 /*
 131  * This routine scans the pid tree and makes sure the rep invariant still
 132  * holds.  Used for debugging only, since it's very slow....
 133  *
 134  * It looks a lot scarier than it really is.... we're doing nothing more
 135  * than verifying the doubly-linked list found in p_ysptr and p_osptr, 
 136  * and checking it corresponds with the process tree defined by p_cptr and 
 137  * p_pptr;
 138  */
 139 void audit_ptree(void)
     /* [previous][next][first][last][top][bottom][index][help] */
 140 {
 141         int     i;
 142 
 143         for (i=1 ; i<NR_TASKS ; i++) {
 144                 if (!task[i])
 145                         continue;
 146                 if (bad_task_ptr(task[i]->p_pptr))
 147                         printk("Warning, pid %d's parent link is bad\n",
 148                                 task[i]->pid);
 149                 if (bad_task_ptr(task[i]->p_cptr))
 150                         printk("Warning, pid %d's child link is bad\n",
 151                                 task[i]->pid);
 152                 if (bad_task_ptr(task[i]->p_ysptr))
 153                         printk("Warning, pid %d's ys link is bad\n",
 154                                 task[i]->pid);
 155                 if (bad_task_ptr(task[i]->p_osptr))
 156                         printk("Warning, pid %d's os link is bad\n",
 157                                 task[i]->pid);
 158                 if (task[i]->p_pptr == task[i])
 159                         printk("Warning, pid %d parent link points to self\n",
 160                                 task[i]->pid);
 161                 if (task[i]->p_cptr == task[i])
 162                         printk("Warning, pid %d child link points to self\n",
 163                                 task[i]->pid);
 164                 if (task[i]->p_ysptr == task[i])
 165                         printk("Warning, pid %d ys link points to self\n",
 166                                 task[i]->pid);
 167                 if (task[i]->p_osptr == task[i])
 168                         printk("Warning, pid %d os link points to self\n",
 169                                 task[i]->pid);
 170                 if (task[i]->p_osptr) {
 171                         if (task[i]->p_pptr != task[i]->p_osptr->p_pptr)
 172                                 printk(
 173                         "Warning, pid %d older sibling %d parent is %d\n",
 174                                 task[i]->pid, task[i]->p_osptr->pid,
 175                                 task[i]->p_osptr->p_pptr->pid);
 176                         if (task[i]->p_osptr->p_ysptr != task[i])
 177                                 printk(
 178                 "Warning, pid %d older sibling %d has mismatched ys link\n",
 179                                 task[i]->pid, task[i]->p_osptr->pid);
 180                 }
 181                 if (task[i]->p_ysptr) {
 182                         if (task[i]->p_pptr != task[i]->p_ysptr->p_pptr)
 183                                 printk(
 184                         "Warning, pid %d younger sibling %d parent is %d\n",
 185                                 task[i]->pid, task[i]->p_osptr->pid,
 186                                 task[i]->p_osptr->p_pptr->pid);
 187                         if (task[i]->p_ysptr->p_osptr != task[i])
 188                                 printk(
 189                 "Warning, pid %d younger sibling %d has mismatched os link\n",
 190                                 task[i]->pid, task[i]->p_ysptr->pid);
 191                 }
 192                 if (task[i]->p_cptr) {
 193                         if (task[i]->p_cptr->p_pptr != task[i])
 194                                 printk(
 195                         "Warning, pid %d youngest child %d has mismatched parent link\n",
 196                                 task[i]->pid, task[i]->p_cptr->pid);
 197                         if (task[i]->p_cptr->p_ysptr)
 198                                 printk(
 199                         "Warning, pid %d youngest child %d has non-NULL ys link\n",
 200                                 task[i]->pid, task[i]->p_cptr->pid);
 201                 }
 202         }
 203 }
 204 #endif /* DEBUG_PROC_TREE */
 205 
 206 /*
 207  * This checks not only the pgrp, but falls back on the pid if no
 208  * satisfactory pgrp is found. I dunno - gdb doesn't work correctly
 209  * without this...
 210  */
 211 int session_of_pgrp(int pgrp)
     /* [previous][next][first][last][top][bottom][index][help] */
 212 {
 213         struct task_struct *p;
 214         int fallback;
 215 
 216         fallback = -1;
 217         for_each_task(p) {
 218                 if (p->session <= 0)
 219                         continue;
 220                 if (p->pgrp == pgrp)
 221                         return p->session;
 222                 if (p->pid == pgrp)
 223                         fallback = p->session;
 224         }
 225         return fallback;
 226 }
 227 
 228 /*
 229  * kill_pg() sends a signal to a process group: this is what the tty
 230  * control characters do (^C, ^Z etc)
 231  */
 232 int kill_pg(int pgrp, int sig, int priv)
     /* [previous][next][first][last][top][bottom][index][help] */
 233 {
 234         struct task_struct *p;
 235         int err,retval = -ESRCH;
 236         int found = 0;
 237 
 238         if (sig<0 || sig>32 || pgrp<=0)
 239                 return -EINVAL;
 240         for_each_task(p) {
 241                 if (p->pgrp == pgrp) {
 242                         if ((err = send_sig(sig,p,priv)) != 0)
 243                                 retval = err;
 244                         else
 245                                 found++;
 246                 }
 247         }
 248         return(found ? 0 : retval);
 249 }
 250 
 251 /*
 252  * kill_sl() sends a signal to the session leader: this is used
 253  * to send SIGHUP to the controlling process of a terminal when
 254  * the connection is lost.
 255  */
 256 int kill_sl(int sess, int sig, int priv)
     /* [previous][next][first][last][top][bottom][index][help] */
 257 {
 258         struct task_struct *p;
 259         int err,retval = -ESRCH;
 260         int found = 0;
 261 
 262         if (sig<0 || sig>32 || sess<=0)
 263                 return -EINVAL;
 264         for_each_task(p) {
 265                 if (p->session == sess && p->leader) {
 266                         if ((err = send_sig(sig,p,priv)) != 0)
 267                                 retval = err;
 268                         else
 269                                 found++;
 270                 }
 271         }
 272         return(found ? 0 : retval);
 273 }
 274 
 275 int kill_proc(int pid, int sig, int priv)
     /* [previous][next][first][last][top][bottom][index][help] */
 276 {
 277         struct task_struct *p;
 278 
 279         if (sig<0 || sig>32)
 280                 return -EINVAL;
 281         for_each_task(p) {
 282                 if (p && p->pid == pid)
 283                         return send_sig(sig,p,priv);
 284         }
 285         return(-ESRCH);
 286 }
 287 
 288 /*
 289  * POSIX specifies that kill(-1,sig) is unspecified, but what we have
 290  * is probably wrong.  Should make it like BSD or SYSV.
 291  */
 292 asmlinkage int sys_kill(int pid,int sig)
     /* [previous][next][first][last][top][bottom][index][help] */
 293 {
 294         int err, retval = 0, count = 0;
 295 
 296         if (!pid)
 297                 return(kill_pg(current->pgrp,sig,0));
 298         if (pid == -1) {
 299                 struct task_struct * p;
 300                 for_each_task(p) {
 301                         if (p->pid > 1 && p != current) {
 302                                 ++count;
 303                                 if ((err = send_sig(sig,p,0)) != -EPERM)
 304                                         retval = err;
 305                         }
 306                 }
 307                 return(count ? retval : -ESRCH);
 308         }
 309         if (pid < 0) 
 310                 return(kill_pg(-pid,sig,0));
 311         /* Normal kill */
 312         return(kill_proc(pid,sig,0));
 313 }
 314 
 315 /*
 316  * Determine if a process group is "orphaned", according to the POSIX
 317  * definition in 2.2.2.52.  Orphaned process groups are not to be affected
 318  * by terminal-generated stop signals.  Newly orphaned process groups are 
 319  * to receive a SIGHUP and a SIGCONT.
 320  * 
 321  * "I ask you, have you ever known what it is to be an orphan?"
 322  */
 323 int is_orphaned_pgrp(int pgrp)
     /* [previous][next][first][last][top][bottom][index][help] */
 324 {
 325         struct task_struct *p;
 326 
 327         for_each_task(p) {
 328                 if ((p->pgrp != pgrp) || 
 329                     (p->state == TASK_ZOMBIE) ||
 330                     (p->p_pptr->pid == 1))
 331                         continue;
 332                 if ((p->p_pptr->pgrp != pgrp) &&
 333                     (p->p_pptr->session == p->session))
 334                         return 0;
 335         }
 336         return(1);      /* (sighing) "Often!" */
 337 }
 338 
 339 static inline int has_stopped_jobs(int pgrp)
     /* [previous][next][first][last][top][bottom][index][help] */
 340 {
 341         struct task_struct * p;
 342 
 343         for_each_task(p) {
 344                 if (p->pgrp != pgrp)
 345                         continue;
 346                 if (p->state == TASK_STOPPED)
 347                         return(1);
 348         }
 349         return(0);
 350 }
 351 
 352 static inline void forget_original_parent(struct task_struct * father)
     /* [previous][next][first][last][top][bottom][index][help] */
 353 {
 354         struct task_struct * p;
 355 
 356         for_each_task(p) {
 357                 if (p->p_opptr == father)
 358                         if (task[smp_num_cpus]) /* init */
 359                                 p->p_opptr = task[smp_num_cpus];
 360                         else
 361                                 p->p_opptr = task[0];
 362         }
 363 }
 364 
 365 static inline void __exit_files(struct task_struct *tsk)
     /* [previous][next][first][last][top][bottom][index][help] */
 366 {
 367         struct files_struct * files = tsk->files;
 368 
 369         if (files) {
 370                 tsk->files = NULL;
 371                 if (!--files->count) {
 372                         int i;
 373                         for (i=0 ; i<NR_OPEN ; i++) {
 374                                 struct file * filp = files->fd[i];
 375                                 if (!filp)
 376                                         continue;
 377                                 files->fd[i] = NULL;
 378                                 close_fp(filp);
 379                         }
 380                         kfree(files);
 381                 }
 382         }
 383 }
 384 
 385 void exit_files(struct task_struct *tsk)
     /* [previous][next][first][last][top][bottom][index][help] */
 386 {
 387   __exit_files(tsk);
 388 }
 389 
 390 static inline void __exit_fs(struct task_struct *tsk)
     /* [previous][next][first][last][top][bottom][index][help] */
 391 {
 392         struct fs_struct * fs = tsk->fs;
 393 
 394         if (fs) {
 395                 tsk->fs = NULL;
 396                 if (!--fs->count) {
 397                         iput(fs->root);
 398                         iput(fs->pwd);
 399                         kfree(fs);
 400                 }
 401         }
 402 }
 403 
 404 void exit_fs(struct task_struct *tsk)
     /* [previous][next][first][last][top][bottom][index][help] */
 405 {
 406   __exit_fs(tsk);
 407 }
 408 
 409 static inline void __exit_sighand(struct task_struct *tsk)
     /* [previous][next][first][last][top][bottom][index][help] */
 410 {
 411         struct signal_struct * sig = tsk->sig;
 412 
 413         if (sig) {
 414                 tsk->sig = NULL;
 415                 if (!--sig->count) {
 416                         kfree(sig);
 417                 }
 418         }
 419 }
 420 
 421 void exit_sighand(struct task_struct *tsk)
     /* [previous][next][first][last][top][bottom][index][help] */
 422 {
 423   __exit_sighand(tsk);
 424 }
 425 
 426 static inline void exit_mm(void)
     /* [previous][next][first][last][top][bottom][index][help] */
 427 {
 428         struct mm_struct * mm = current->mm;
 429 
 430         current->swappable = 0;
 431         if (mm) {
 432                 if (!--mm->count) {
 433                         exit_mmap(mm);
 434                         free_page_tables(current);
 435                         kfree(mm);
 436                 }
 437                 current->mm = NULL;
 438         }
 439 }
 440 
 441 /* 
 442  * Send signals to all our closest relatives so that they know
 443  * to properly mourn us..
 444  */
 445 static void exit_notify(void)
     /* [previous][next][first][last][top][bottom][index][help] */
 446 {
 447         struct task_struct * p;
 448 
 449         forget_original_parent(current);
 450         /* 
 451          * Check to see if any process groups have become orphaned
 452          * as a result of our exiting, and if they have any stopped
 453          * jobs, send them a SIGHUP and then a SIGCONT.  (POSIX 3.2.2.2)
 454          *
 455          * Case i: Our father is in a different pgrp than we are
 456          * and we were the only connection outside, so our pgrp
 457          * is about to become orphaned.
 458          */
 459         if ((current->p_pptr->pgrp != current->pgrp) &&
 460             (current->p_pptr->session == current->session) &&
 461             is_orphaned_pgrp(current->pgrp) &&
 462             has_stopped_jobs(current->pgrp)) {
 463                 kill_pg(current->pgrp,SIGHUP,1);
 464                 kill_pg(current->pgrp,SIGCONT,1);
 465         }
 466         /* Let father know we died */
 467         notify_parent(current);
 468         
 469         /*
 470          * This loop does two things:
 471          * 
 472          * A.  Make init inherit all the child processes
 473          * B.  Check to see if any process groups have become orphaned
 474          *      as a result of our exiting, and if they have any stopped
 475          *      jobs, send them a SIGHUP and then a SIGCONT.  (POSIX 3.2.2.2)
 476          */
 477         while ((p = current->p_cptr) != NULL) {
 478                 current->p_cptr = p->p_osptr;
 479                 p->p_ysptr = NULL;
 480                 p->flags &= ~(PF_PTRACED|PF_TRACESYS);
 481                 if (task[smp_num_cpus] && task[smp_num_cpus] != current) /* init */
 482                         p->p_pptr = task[smp_num_cpus];
 483                 else
 484                         p->p_pptr = task[0];
 485                 p->p_osptr = p->p_pptr->p_cptr;
 486                 p->p_osptr->p_ysptr = p;
 487                 p->p_pptr->p_cptr = p;
 488                 if (p->state == TASK_ZOMBIE)
 489                         notify_parent(p);
 490                 /*
 491                  * process group orphan check
 492                  * Case ii: Our child is in a different pgrp 
 493                  * than we are, and it was the only connection
 494                  * outside, so the child pgrp is now orphaned.
 495                  */
 496                 if ((p->pgrp != current->pgrp) &&
 497                     (p->session == current->session) &&
 498                     is_orphaned_pgrp(p->pgrp) &&
 499                     has_stopped_jobs(p->pgrp)) {
 500                         kill_pg(p->pgrp,SIGHUP,1);
 501                         kill_pg(p->pgrp,SIGCONT,1);
 502                 }
 503         }
 504         if (current->leader)
 505                 disassociate_ctty(1);
 506 }
 507 
 508 NORET_TYPE void do_exit(long code)
     /* [previous][next][first][last][top][bottom][index][help] */
 509 {
 510         if (intr_count) {
 511                 printk("Aiee, killing interrupt handler\n");
 512                 intr_count = 0;
 513         }
 514 fake_volatile:
 515         acct_process(code);
 516         current->flags |= PF_EXITING;
 517         del_timer(&current->real_timer);
 518         sem_exit();
 519         kerneld_exit();
 520         exit_mm();
 521         __exit_files(current);
 522         __exit_fs(current);
 523         __exit_sighand(current);
 524         exit_thread();
 525         current->state = TASK_ZOMBIE;
 526         current->exit_code = code;
 527         exit_notify();
 528 #ifdef DEBUG_PROC_TREE
 529         audit_ptree();
 530 #endif
 531         if (current->exec_domain && current->exec_domain->use_count)
 532                 (*current->exec_domain->use_count)--;
 533         if (current->binfmt && current->binfmt->use_count)
 534                 (*current->binfmt->use_count)--;
 535         schedule();
 536 /*
 537  * In order to get rid of the "volatile function does return" message
 538  * I did this little loop that confuses gcc to think do_exit really
 539  * is volatile. In fact it's schedule() that is volatile in some
 540  * circumstances: when current->state = ZOMBIE, schedule() never
 541  * returns.
 542  *
 543  * In fact the natural way to do all this is to have the label and the
 544  * goto right after each other, but I put the fake_volatile label at
 545  * the start of the function just in case something /really/ bad
 546  * happens, and the schedule returns. This way we can try again. I'm
 547  * not paranoid: it's just that everybody is out to get me.
 548  */
 549         goto fake_volatile;
 550 }
 551 
 552 asmlinkage int sys_exit(int error_code)
     /* [previous][next][first][last][top][bottom][index][help] */
 553 {
 554         do_exit((error_code&0xff)<<8);
 555 }
 556 
 557 asmlinkage int sys_wait4(pid_t pid,unsigned int * stat_addr, int options, struct rusage * ru)
     /* [previous][next][first][last][top][bottom][index][help] */
 558 {
 559         int flag, retval;
 560         struct wait_queue wait = { current, NULL };
 561         struct task_struct *p;
 562 
 563         if (stat_addr) {
 564                 flag = verify_area(VERIFY_WRITE, stat_addr, sizeof(*stat_addr));
 565                 if (flag)
 566                         return flag;
 567         }
 568         if (ru) {
 569                 flag = verify_area(VERIFY_WRITE, ru, sizeof(*ru));
 570                 if (flag)
 571                         return flag;
 572         }
 573         add_wait_queue(&current->wait_chldexit,&wait);
 574 repeat:
 575         flag=0;
 576         for (p = current->p_cptr ; p ; p = p->p_osptr) {
 577                 if (pid>0) {
 578                         if (p->pid != pid)
 579                                 continue;
 580                 } else if (!pid) {
 581                         if (p->pgrp != current->pgrp)
 582                                 continue;
 583                 } else if (pid != -1) {
 584                         if (p->pgrp != -pid)
 585                                 continue;
 586                 }
 587                 /* wait for cloned processes iff the __WCLONE flag is set */
 588                 if ((p->exit_signal != SIGCHLD) ^ ((options & __WCLONE) != 0))
 589                         continue;
 590                 flag = 1;
 591                 switch (p->state) {
 592                         case TASK_STOPPED:
 593                                 if (!p->exit_code)
 594                                         continue;
 595                                 if (!(options & WUNTRACED) && !(p->flags & PF_PTRACED))
 596                                         continue;
 597                                 if (ru != NULL)
 598                                         getrusage(p, RUSAGE_BOTH, ru);
 599                                 if (stat_addr)
 600                                         put_user((p->exit_code << 8) | 0x7f,
 601                                                 stat_addr);
 602                                 p->exit_code = 0;
 603                                 retval = p->pid;
 604                                 goto end_wait4;
 605                         case TASK_ZOMBIE:
 606                                 current->cutime += p->utime + p->cutime;
 607                                 current->cstime += p->stime + p->cstime;
 608                                 if (ru != NULL)
 609                                         getrusage(p, RUSAGE_BOTH, ru);
 610                                 if (stat_addr)
 611                                         put_user(p->exit_code, stat_addr);
 612                                 retval = p->pid;
 613                                 if (p->p_opptr != p->p_pptr) {
 614                                         REMOVE_LINKS(p);
 615                                         p->p_pptr = p->p_opptr;
 616                                         SET_LINKS(p);
 617                                         notify_parent(p);
 618                                 } else
 619                                         release(p);
 620 #ifdef DEBUG_PROC_TREE
 621                                 audit_ptree();
 622 #endif
 623                                 goto end_wait4;
 624                         default:
 625                                 continue;
 626                 }
 627         }
 628         if (flag) {
 629                 retval = 0;
 630                 if (options & WNOHANG)
 631                         goto end_wait4;
 632                 current->state=TASK_INTERRUPTIBLE;
 633                 schedule();
 634                 current->signal &= ~(1<<(SIGCHLD-1));
 635                 retval = -ERESTARTSYS;
 636                 if (current->signal & ~current->blocked)
 637                         goto end_wait4;
 638                 goto repeat;
 639         }
 640         retval = -ECHILD;
 641 end_wait4:
 642         remove_wait_queue(&current->wait_chldexit,&wait);
 643         return retval;
 644 }
 645 
 646 #ifndef __alpha__
 647 
 648 /*
 649  * sys_waitpid() remains for compatibility. waitpid() should be
 650  * implemented by calling sys_wait4() from libc.a.
 651  */
 652 asmlinkage int sys_waitpid(pid_t pid,unsigned int * stat_addr, int options)
     /* [previous][next][first][last][top][bottom][index][help] */
 653 {
 654         return sys_wait4(pid, stat_addr, options, NULL);
 655 }
 656 
 657 #endif

/* [previous][next][first][last][top][bottom][index][help] */