Lines Matching refs:pid

59 	pid_t		pid;
70 pid_t pid;
73 if(sizeof(pid)==sizeof(Sflong_t))
74 pid = (pid_t)strtoll(str, &last, 10);
76 pid = (pid_t)strtol(str, &last, 10);
79 return(pid);
233 static struct jobsave *jobsave_create(pid_t pid)
236 job_chksave(pid);
248 jp->pid = pid;
263 char *sh_pid2str(Shell_t *shp,pid_t pid)
266 if(pid&COPID_BIT)
268 int id = (pid>>16) &0x3f;
276 sfprintf(shp->strbuf,"%s.%d%c",csp->name,pid&0xff,0);
278 sfprintf(shp->strbuf,"%d%c",pid,0);
339 register pid_t pid;
357 pid = 0;
366 if(sfprintf(sfstderr,"ksh: job line %4d: reap pid=%d critical=%d signal=%d\n",__LINE__,getpid(),job.in_critical,sig) <=0)
393 pid = sh_copid(csp);
406 pid = waitpid((pid_t)-1,&wstat,flags);
417 if (pid<0 && errno==EINVAL && (flags&WCONTINUED))
418 pid = waitpid((pid_t)-1,&wstat,flags&=~WCONTINUED);
420 if(pid<0 && errno==EINTR && (sig||job.savesig))
425 if(pid<=0)
428 job_chksave(pid);
432 lastpid = pid;
433 if(!(pw=job_bypid(pid)))
436 sfprintf(sfstderr,"ksh: job line %4d: reap pid=%d critical=%d unknown job pid=%d pw=%x\n",__LINE__,getpid(),job.in_critical,pid,pw);
446 jp = jobsave_create(pid);
448 lastpid = pw->p_pid = pid;
480 if(pid==shp->cpid)
488 sh_subjobcheck(pid);
541 sfprintf(sfstderr,"ksh: job line %4d: reap pid=%d critical=%d job %d with pid %d flags=%o complete with status=%x exit=%d\n",__LINE__,getpid(),job.in_critical,pw->p_job,pid,pw->p_flag,wstat,pw->p_exit);
547 if(pid==pw->p_fgrp && pid==tcgetpgrp(JOBTTY))
555 if(!shp->intrap && shp->st.trapcom[SIGCHLD] && pid>0 && (pwfg!=job_bypid(pid)))
642 setpgid(0,shp->gd->pid);
651 job.mypgid = shp->gd->pid;
653 tcsetpgrp(JOBTTY,shp->gd->pid);
654 setpgid(0,shp->gd->pid);
668 kill(shp->gd->pid,SIGTTIN);
709 setpgid(0,shp->gd->pid);
723 tcsetpgrp(JOBTTY,shp->gd->pid);
736 job.mypid = shp->gd->pid;
834 if((pw->p_flag&P_STOPPED) || tcgetpgrp(job.fd) == shp->gd->pid)
873 register pid_t pid;
885 pid = pw->p_pid;
898 pid = pid_fromstring(jp);
899 job_wait(-pid);
960 int pid = pid_fromstring(jobid);
961 if(!(pw = job_bypid(pid)))
965 pw->p_pid = pid;
966 pw->p_pgrp = pid;
1115 register pid_t pid;
1127 pid = pw->p_pid;
1135 if(pid==0 && job.jobcontrol)
1138 if(sig==SIGSTOP && pid==shp->gd->pid && shp->gd->ppid==1)
1146 if(pid>=0)
1148 if((r = kill(pid,sig))>=0 && !stopsig)
1153 kill(pid,SIGCONT);
1158 if((r = killpg(-pid,sig))>=0 && !stopsig)
1162 killpg(-pid,SIGCONT);
1167 if(pid>=0)
1168 r = kill(pid,sig);
1170 r = killpg(-pid,sig);
1175 if(pid = pw->p_pgrp)
1177 r = killpg(pid,sig);
1291 * put the process <pid> on the process list and return the job number
1295 int job_post(Shell_t *shp,pid_t pid, pid_t join)
1321 if(pw = job_bypid(pid))
1361 if(shp->coshell && (pid&COPID_BIT))
1364 job.curpgid = sh_isstate(SH_MONITOR)?pid:0;
1370 pw->p_pid = pid;
1371 if(!shp->outpipe || shp->cpid==pid)
1378 job.curpgid = pid;
1385 sfprintf(sfstderr,"ksh: job line %4d: post pid=%d critical=%d job=%d pid=%d pgid=%d savesig=%d join=%d\n",__LINE__,getpid(),job.in_critical,pw->p_job,
1395 if ((val = job_chksave(pid))>=0 && !jobfork)
1429 static struct process *job_bypid(pid_t pid)
1435 if(px->p_pid==pid)
1478 * Wait for process pid to complete
1479 * If pid < -1, then wait can be interrupted, -pid is waited for (wait builtin)
1480 * pid=0 to unpost all done processes
1481 * pid=1 to wait for at least one process to complete
1482 * pid=-1 to wait for all runing processes
1485 int job_wait(register pid_t pid)
1492 if(pid < 0)
1494 pid = -pid;
1498 if(pid==0)
1510 if(pid > 1)
1512 if(pid==shp->spid)
1514 if(!(pw=job_bypid(pid)))
1517 if((shp->exitval = job_chksave(pid)) < 0)
1537 sfprintf(sfstderr,"ksh: job line %4d: wait pid=%d critical=%d job=%d pid=%d\n",__LINE__,getpid(),job.in_critical,jobid,pid);
1539 sfprintf(sfstderr,"ksh: job line %4d: wait pid=%d critical=%d flags=%o\n",__LINE__,getpid(),job.in_critical,pw->p_flag);
1627 if((intr && shp->trapnote) || (pid==1 && !intr))
1634 if(pid==1)
1637 if(pid==0)
1793 sfprintf(sfstderr,"ksh: job line %4d: drop pid=%d critical=%d pid=%d env=%d\n",__LINE__,getpid(),job.in_critical,pwtop->p_pid,pwtop->p_env);
1832 sfprintf(sfstderr,"ksh: job line %4d: free pid=%d critical=%d job=%d\n",__LINE__,getpid(),job.in_critical,pwtop->p_job);
1936 * if pid==0, then oldest saved process is deleted
1937 * If pid is not found a -1 is returned.
1939 static int job_chksave(register pid_t pid)
1948 if(jp->pid==pid)
1950 if(pid==0 && !jp->next)
1955 if(!jp && pid && (bp=bp->prev))
1964 if(pid)
2038 sfprintf(sfstderr,"ksh: job line %4d: fork pid=%d critical=%d parent=%d\n",__LINE__,getpid(),job.in_critical,parent);