Lines Matching refs:sig
22 * trap [-p] action sig...
23 * kill [-l] [sig...]
24 * kill [-s sig] pid...
47 register int sig, clear = 0, dflag = 0, pflag = 0;
50 while (sig = optget(argv, sh_opttrap)) switch (sig)
96 sig = sig_number(shp,arg);
97 if(sig<0)
103 if(sig&SH_TRAP)
105 sig &= ~SH_TRAP;
106 if(sig>SH_DEBUGTRAP)
113 if(arg=shp->st.trap[sig])
117 if(shp->st.trap[sig])
118 free(shp->st.trap[sig]);
119 shp->st.trap[sig] = 0;
121 shp->st.trap[sig] = strdup(action);
122 if(sig == SH_DEBUGTRAP)
124 if(shp->st.trap[sig])
131 if(sig>shp->gd->sigmax)
139 if(arg=trapcom[sig])
144 sh_sigclear(sig);
146 signal(sig,SIG_DFL);
150 if(sig >= shp->st.trapmax)
151 shp->st.trapmax = sig+1;
152 arg = shp->st.trapcom[sig];
153 sh_sigtrap(sig);
154 shp->st.trapcom[sig] = (shp->sigflag[sig]&SH_SIGOFF) ? Empty : strdup(action);
168 register int sig=SIGTERM, flag=0, n;
174 if((signame=argv[opt_info.index++]) && (sig=sig_number(shp,signame+1))>=0)
180 sig = (int)opt_info.num;
211 if((sig=sig_number(shp,signame))<0)
216 sfprintf(sfstdout,"%d\n",sig);
223 if((sig=sig_number(shp,signame)) < 0 || sig > shp->gd->sigmax)
226 if(job_walk(sfstdout,job_kill,sig,argv))
238 register int n,o,sig=0;
261 sig = 1;
272 if(sig==1 && (n>=(SH_TRAP-1) && n < (1<<SH_SIGBITS)))
274 /* sig prefix cannot match internal traps */
292 if((sig=(int)strtol(name+4,&name,10)) >= 0 && !*name)
293 n = shp->gd->sigruntime[SH_SIGRTMIN] + sig;
297 if((sig=(int)strtol(name+4,&name,10)) >= 0 && !*name)
298 n = shp->gd->sigruntime[SH_SIGRTMAX] - sig;
300 else if((sig=(int)strtol(name,&name,10)) > 0 && !*name)
301 n = shp->gd->sigruntime[SH_SIGRTMIN] + sig - 1;
310 * synthesize signal name for sig in buf
313 static char* sig_name(Shell_t *shp,int sig, char* buf, int pfx)
318 if(sig>shp->gd->sigruntime[SH_SIGRTMIN] && sig<shp->gd->sigruntime[SH_SIGRTMAX])
323 if(sig>shp->gd->sigruntime[SH_SIGRTMIN]+(shp->gd->sigruntime[SH_SIGRTMAX]-shp->gd->sigruntime[SH_SIGRTMIN])/2)
328 sig = shp->gd->sigruntime[SH_SIGRTMAX]-sig;
335 sig = sig-shp->gd->sigruntime[SH_SIGRTMIN];
344 i += sfsprintf(buf+i, 8, "%d", sig);
357 register int sig;
366 for(sig=shp->gd->sigmax; sig>=0; sig--)
367 names[sig] = 0;
368 for(sig=SH_DEBUGTRAP; sig>=0; sig--)
369 traps[sig] = 0;
373 sig = tp->sh_number&((1<<SH_SIGBITS)-1);
374 if (((tp->sh_number>>SH_SIGBITS) & SH_SIGRUNTIME) && (sig = shp->gd->sigruntime[sig-1]+1) == 1)
376 if(sig==flag)
381 else if(sig&SH_TRAP)
382 traps[sig&~SH_TRAP] = (char*)tp->sh_name;
383 else if(sig-- && sig < elementsof(names))
384 names[sig] = (char*)tp->sh_name;
392 sig = shp->st.trapmax;
395 while(--sig >= 0)
397 if(!(trap=trapcom[sig]))
399 if(sig > shp->gd->sigmax || !(sname=(char*)names[sig]))
400 sname = sig_name(shp,sig,name,1);
403 for(sig=SH_DEBUGTRAP; sig>=0; sig--)
405 if(!(trap=shp->st.trap[sig]))
407 sfprintf(sfstdout,trapfmt,sh_fmtq(trap),traps[sig]);
413 for(sig=1; sig <= shp->gd->sigmax; sig++)
415 if(!(sname=(char*)names[sig]))
416 sname = sig_name(shp,sig,name,1);