/* * Handle all error exit scenarios for the shell. This includes * setting the exit status to the appropriate value according to * es and causing the shell to exit if appropriate. This function * is called by err() and may or may not return. */ static void sh_errexit(int es) { #ifdef DEBUG fd_print(FD2,"sh_errexit: getmypid() == %d, es == %d;\n",getmypid(),es); #endif status = es; if (prompt == NULL) { (void)lseek(FD0, (off_t)0, SEEK_END); EXIT(status); } if (getpid() != getmypid()) _exit(status); }
char *lpm_getmsg (void) { static xmesg rc; int arg = getmypid (); *rc = 0; return lpm_call (LPMGETMSG, (char *)&arg, (char *)&rc) && *rc ? rc : NULL; }
int lpm_pque (int pri, char *prog, char *msg) { LpmQue arg; setstring (arg.name, prog); setstring (arg.mesg, msg); arg.pid = getmypid (); arg.pri = pri; lpm_call_int (LPMQUE); }
int lpm_verify (void) { int arg = getmypid (); ulong rc = 0; if (!lpm_call (LPMVERIFY, (char *)&arg, (char *)&rc)) return LpmRpcError == RPC_PROCUNAVAIL; if (lpm_nom != rc) return 0; return 1; }
/* * Initialize the shell. */ static void sh_init(const char *av0p) { struct stat sb; int i; setmyerrexit(&sh_errexit); setmyname(av0p); setmypid(getpid()); /* * Set-ID execution is not supported. */ if (geteuid() != getuid() || getegid() != getgid()) err(SH_ERR, FMT1S, ERR_SETID); /* * Save the process ID of the shell as a 5-digit ASCII * string (apid). Each occurrence of `$$' in a command * line is substituted w/ the value of apid. */ i = snprintf(apid, sizeof(apid), "%05u", (unsigned)getmypid()); if (i < 0 || i >= (int)sizeof(apid)) *apid = EOS; /* * Fail if any of the descriptors 0, 1, or 2 is not open. */ for (i = 0; i < 3; i++) if (fstat(i, &sb) == -1) err(SH_ERR, "%u: %s\n", (unsigned)i, strerror(errno)); /* * Set the SIGCHLD signal to its default action. * Correct operation of the shell requires that zombies * be created for its children when they terminate. */ (void)sasignal(SIGCHLD, SIG_DFL); }
unsigned int lpm_query (int nom, int rev) { LpmQry arg; unsigned int rc = 0; arg.pid = getmypid (); arg.nom = nom; arg.rev = rev; if (rev == LPM_Option) if (!lpm_optinrange (nom)) return 0; if (!lpm_call (LPMQUERY, (char *)&arg, (char *)&rc)) return 0; else if (rev == LPM_Option) return rc; else if (rc) { lpm_setbit (lpm_nom, nom); return rc; } else return 0; }
int lpm_bye (void) { int arg = getmypid (); lpm_call_int (LPMBYE); }
int lpm_init (void) { int arg = getmypid (); lpm_call_int (LPMINIT); }