Annotation of 43BSDReno/sys/hpux/hpux_sig.c, revision 1.1

1.1     ! root        1: /*
        !             2:  * Copyright (c) 1988 University of Utah.
        !             3:  * Copyright (c) 1990 The Regents of the University of California.
        !             4:  * All rights reserved.
        !             5:  *
        !             6:  * This code is derived from software contributed to Berkeley by
        !             7:  * the Systems Programming Group of the University of Utah Computer
        !             8:  * Science Department.
        !             9:  *
        !            10:  * Redistribution is only permitted until one year after the first shipment
        !            11:  * of 4.4BSD by the Regents.  Otherwise, redistribution and use in source and
        !            12:  * binary forms are permitted provided that: (1) source distributions retain
        !            13:  * this entire copyright notice and comment, and (2) distributions including
        !            14:  * binaries display the following acknowledgement:  This product includes
        !            15:  * software developed by the University of California, Berkeley and its
        !            16:  * contributors'' in the documentation or other materials provided with the
        !            17:  * distribution and in all advertising materials mentioning features or use
        !            18:  * of this software.  Neither the name of the University nor the names of
        !            19:  * its contributors may be used to endorse or promote products derived from
        !            20:  * this software without specific prior written permission.
        !            21:  * THIS SOFTWARE IS PROVIDED AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
        !            22:  * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
        !            23:  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
        !            24:  *
        !            25:  * from: Utah $Hdr: hpux_compat.c 1.33 89/08/23$
        !            26:  *
        !            27:  *     @(#)hpux_sig.c  7.4 (Berkeley) 6/28/90
        !            28:  */
        !            29: 
        !            30: /*
        !            31:  * Signal related HPUX compatibility routines
        !            32:  */
        !            33: 
        !            34: #ifdef HPUXCOMPAT
        !            35: 
        !            36: #include "param.h"
        !            37: #include "systm.h"
        !            38: #include "user.h"
        !            39: #include "kernel.h"
        !            40: #include "proc.h"
        !            41: #include "hpux.h"
        !            42: 
        !            43: /* indexed by HPUX signal number - 1 */
        !            44: char hpuxtobsdsigmap[NSIG] = {
        !            45: /*01*/ SIGHUP,  SIGINT, SIGQUIT, SIGILL,   SIGTRAP, SIGIOT,  SIGEMT,   SIGFPE,
        !            46: /*09*/  SIGKILL, SIGBUS, SIGSEGV, SIGSYS,   SIGPIPE, SIGALRM, SIGTERM,  SIGUSR1,
        !            47: /*17*/  SIGUSR2, SIGCHLD, 0,      SIGVTALRM,SIGPROF, SIGIO,   SIGWINCH, SIGSTOP,
        !            48: /*25*/ SIGTSTP, SIGCONT,SIGTTIN, SIGTTOU,  SIGURG,  0,       0,        0
        !            49: };
        !            50: 
        !            51: /* indexed by BSD signal number - 1 */
        !            52: char bsdtohpuxsigmap[NSIG] = {
        !            53: /*01*/  1,  2,  3,  4,  5,  6,  7,  8,
        !            54: /*09*/   9, 10, 11, 12, 13, 14, 15, 29,
        !            55: /*17*/  24, 25, 26, 18, 27, 28, 22,  0,
        !            56: /*25*/  0, 20, 21, 23,  0, 16, 17,  0
        !            57: };
        !            58: 
        !            59: /*
        !            60:  * XXX: In addition to mapping the signal number we also have
        !            61:  * to see if the "old" style signal mechinism is needed.
        !            62:  * If so, we set the OUSIG flag.  This is not really correct
        !            63:  * as under HP-UX "old" style handling can be set on a per
        !            64:  * signal basis and we are setting it for all signals in one
        !            65:  * swell foop.  I suspect we can get away with this since I
        !            66:  * doubt any program of interest mixes the two semantics.
        !            67:  */
        !            68: hpuxsigvec(p, uap, retval)
        !            69:        struct proc *p;
        !            70:        register struct args {
        !            71:                int     signo;
        !            72:                struct  sigvec *nsv;
        !            73:                struct  sigvec *osv;
        !            74:        } *uap;
        !            75:        int *retval;
        !            76: {
        !            77:        struct sigvec vec;
        !            78:        register struct sigvec *sv;
        !            79:        register int sig;
        !            80:        int bit, error;
        !            81: 
        !            82:        sig = hpuxtobsdsig(uap->signo);
        !            83:        if (sig <= 0 || sig >= NSIG || sig == SIGKILL || sig == SIGSTOP)
        !            84:                return (EINVAL);
        !            85:        sv = &vec;
        !            86:        if (uap->osv) {
        !            87:                sv->sv_handler = u.u_signal[sig];
        !            88:                sv->sv_mask = u.u_sigmask[sig];
        !            89:                bit = sigmask(sig);
        !            90:                sv->sv_flags = 0;
        !            91:                if ((u.u_sigonstack & bit) != 0)
        !            92:                        sv->sv_flags |= SV_ONSTACK;
        !            93:                if ((u.u_sigintr & bit) != 0)
        !            94:                        sv->sv_flags |= SV_INTERRUPT;
        !            95: #if 0
        !            96: /* XXX -- SOUSIG no longer exists, do something here */
        !            97:                if (p->p_flag & SOUSIG)
        !            98:                        sv->sv_flags |= HPUXSV_RESET;           /* XXX */
        !            99: #endif
        !           100:                error = copyout((caddr_t)sv, (caddr_t)uap->osv, sizeof (vec));
        !           101:                if (error)
        !           102:                        return (error);
        !           103:        }
        !           104:        if (uap->nsv) {
        !           105:                error = copyin((caddr_t)uap->nsv, (caddr_t)sv, sizeof (vec));
        !           106:                if (error)
        !           107:                        return (error);
        !           108:                if (sig == SIGCONT && sv->sv_handler == SIG_IGN)
        !           109:                        return (EINVAL);
        !           110:                setsigvec(p, sig, (struct sigaction *)sv);
        !           111: #if 0
        !           112: /* XXX -- SOUSIG no longer exists, do something here */
        !           113:                if (sv->sv_flags & HPUXSV_RESET)
        !           114:                        p->p_flag |= SOUSIG;            /* XXX */
        !           115: #endif
        !           116:        }
        !           117:        return (0);
        !           118: }
        !           119: 
        !           120: hpuxsigblock(p, uap, retval)
        !           121:        register struct proc *p;
        !           122:        struct args {
        !           123:                int     mask;
        !           124:        } *uap;
        !           125:        int *retval;
        !           126: {
        !           127: 
        !           128:        (void) splhigh();
        !           129:        *retval = bsdtohpuxmask(p->p_sigmask);
        !           130:        p->p_sigmask |= hpuxtobsdmask(uap->mask) &~ sigcantmask;
        !           131:        (void) spl0();
        !           132:        return (0);
        !           133: }
        !           134: 
        !           135: hpuxsigsetmask(p, uap, retval)
        !           136:        struct proc *p;
        !           137:        struct args {
        !           138:                int     mask;
        !           139:        } *uap;
        !           140:        int *retval;
        !           141: {
        !           142: 
        !           143:        (void) splhigh();
        !           144:        *retval = bsdtohpuxmask(p->p_sigmask);
        !           145:        p->p_sigmask = hpuxtobsdmask(uap->mask) &~ sigcantmask;
        !           146:        (void) spl0();
        !           147:        return (0);
        !           148: }
        !           149: 
        !           150: hpuxsigpause(p, uap, retval)
        !           151:        struct proc *p;
        !           152:        struct args {
        !           153:                int     mask;
        !           154:        } *uap;
        !           155:        int *retval;
        !           156: {
        !           157: 
        !           158:        uap->mask = hpuxtobsdmask(uap->mask);
        !           159:        return (sigsuspend(p, uap, retval));
        !           160: }
        !           161: 
        !           162: /* not totally correct, but close enuf' */
        !           163: hpuxkill(p, uap, retval)
        !           164:        struct proc *p;
        !           165:        struct args {
        !           166:                int     pid;
        !           167:                int     signo;
        !           168:        } *uap;
        !           169:        int *retval;
        !           170: {
        !           171: 
        !           172:        if (uap->signo) {
        !           173:                uap->signo = hpuxtobsdsig(uap->signo);
        !           174:                if (uap->signo == 0)
        !           175:                        uap->signo = NSIG;
        !           176:        }
        !           177:        return (kill(p, uap, retval));
        !           178: }
        !           179: 
        !           180: ohpuxssig(p, uap, retval)
        !           181:        struct proc *p;
        !           182:        struct args {
        !           183:                int     signo;
        !           184:                sig_t   fun;
        !           185:        } *uap;
        !           186:        int *retval;
        !           187: {
        !           188:        register int a;
        !           189:        struct sigvec vec;
        !           190:        register struct sigvec *sv = &vec;
        !           191: 
        !           192:        a = hpuxtobsdsig(uap->signo);
        !           193:        sv->sv_handler = uap->fun;
        !           194:        /*
        !           195:         * Kill processes trying to use job control facilities
        !           196:         * (this'll help us find any vestiges of the old stuff).
        !           197:         */
        !           198:        if ((a &~ 0377) ||
        !           199:            (sv->sv_handler != SIG_DFL && sv->sv_handler != SIG_IGN &&
        !           200:             ((int)sv->sv_handler) & 1)) {
        !           201:                psignal(p, SIGSYS);
        !           202:                return (0);
        !           203:        }
        !           204:        if (a <= 0 || a >= NSIG || a == SIGKILL || a == SIGSTOP ||
        !           205:            a == SIGCONT && sv->sv_handler == SIG_IGN)
        !           206:                return (EINVAL);
        !           207:        sv->sv_mask = 0;
        !           208:        sv->sv_flags = SV_INTERRUPT;
        !           209:        *retval = (int)u.u_signal[a];
        !           210:        setsigvec(p, a, (struct sigaction *)sv);
        !           211: #if 0
        !           212:        p->p_flag |= SOUSIG;            /* mark as simulating old stuff */
        !           213: #endif
        !           214:        return (0);
        !           215: }
        !           216: 
        !           217: /* signal numbers: convert from HPUX to BSD */
        !           218: hpuxtobsdsig(sig)
        !           219:        register int sig;
        !           220: {
        !           221:        if (--sig < 0 || sig >= NSIG)
        !           222:                return(0);
        !           223:        return((int)hpuxtobsdsigmap[sig]);
        !           224: }
        !           225: 
        !           226: /* signal numbers: convert from BSD to HPUX */
        !           227: bsdtohpuxsig(sig)
        !           228:        register int sig;
        !           229: {
        !           230:        if (--sig < 0 || sig >= NSIG)
        !           231:                return(0);
        !           232:        return((int)bsdtohpuxsigmap[sig]);
        !           233: }
        !           234: 
        !           235: /* signal masks: convert from HPUX to BSD (not pretty or fast) */
        !           236: hpuxtobsdmask(mask)
        !           237:        register int mask;
        !           238: {
        !           239:        register int nmask, sig, nsig;
        !           240: 
        !           241:        if (mask == 0 || mask == -1)
        !           242:                return(mask);
        !           243:        nmask = 0;
        !           244:        for (sig = 1; sig < NSIG; sig++)
        !           245:                if ((mask & sigmask(sig)) && (nsig = hpuxtobsdsig(sig)))
        !           246:                        nmask |= sigmask(nsig);
        !           247:        return(nmask);
        !           248: }
        !           249: 
        !           250: bsdtohpuxmask(mask)
        !           251:        register int mask;
        !           252: {
        !           253:        register int nmask, sig, nsig;
        !           254: 
        !           255:        if (mask == 0 || mask == -1)
        !           256:                return(mask);
        !           257:        nmask = 0;
        !           258:        for (sig = 1; sig < NSIG; sig++)
        !           259:                if ((mask & sigmask(sig)) && (nsig = bsdtohpuxsig(sig)))
        !           260:                        nmask |= sigmask(nsig);
        !           261:        return(nmask);
        !           262: }
        !           263: #endif

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.