Lines Matching refs:sp
228 struct sactab *sp; /* working pointer */ in startpms() local
238 for (sp = Sactab; sp; sp = sp->sc_next) { in startpms()
239 if (checklock(sp)) { in startpms()
241 sp->sc_sstate = sp->sc_pstate = UNKNOWN; in startpms()
242 sp->sc_ok = 1; in startpms()
243 sp->sc_exit = 0; in startpms()
244 (void) sprintf(Scratch, "%s/_pmpipe", sp->sc_tag); in startpms()
245 sp->sc_fd = open(Scratch, O_RDWR); in startpms()
246 if (sp->sc_fd < 0) { in startpms()
258 sp->sc_tag); in startpms()
260 (void) sendsig(sp, SIGTERM); in startpms()
261 sp->sc_ok = 0; in startpms()
275 for (sp = Sactab; sp; sp = sp->sc_next) { in startpms()
276 if (sp->sc_flags & X_FLAG) { in startpms()
280 (void) startpm(sp); in startpms()
301 struct sactab *sp; /* working pointer */ in readutmpx() local
316 sp = findpm(uxp->ut_user); in readutmpx()
317 if (sp && (sp->sc_sstate == UNKNOWN)) { in readutmpx()
319 (void) memcpy(sp->sc_utid, uxp->ut_id, IDLEN); in readutmpx()
320 sp->sc_pid = uxp->ut_pid; in readutmpx()
332 for (sp = Sactab; sp; sp = sp->sc_next) { in readutmpx()
333 if (strncmp(uxp->ut_user, sp->sc_tag, in readutmpx()
340 sp->sc_tag); in readutmpx()
344 savesp = sp; in readutmpx()
370 startpm(struct sactab *sp) in startpm() argument
380 if (checklock(sp)) { in startpm()
382 "could not start <%s> - _pid file locked", sp->sc_tag); in startpm()
387 (void) sprintf(Scratch, "%s/_pmpipe", sp->sc_tag); in startpm()
394 sp->sc_tag, errno); in startpm()
399 sp->sc_fd = open(Scratch, O_RDWR); in startpm()
400 if (sp->sc_fd < 0) { in startpm()
403 sp->sc_tag, errno); in startpm()
415 "Could not fork port monitor <%s>", sp->sc_tag); in startpm()
419 startit(sp); in startpm()
427 cleanutx(sp); in startpm()
433 account(sp, pid); in startpm()
434 sp->sc_pstate = STARTING; in startpm()
435 if (sp->sc_lstate == NOTRUNNING) in startpm()
436 sp->sc_sstate = (sp->sc_flags & D_FLAG) ? DISABLED : ENABLED; in startpm()
438 sp->sc_sstate = sp->sc_lstate; in startpm()
439 sp->sc_ok = 1; in startpm()
440 sp->sc_exit = 0; in startpm()
441 sp->sc_pid = pid; in startpm()
457 cleanutx(struct sactab *sp) in cleanutx() argument
475 zerocheck += sp->sc_utid[i]; in cleanutx()
480 pid = sp->sc_pid; in cleanutx()
506 up->ut_exit.e_termination = WTERMSIG(sp->sc_exit); in cleanutx()
507 up->ut_exit.e_exit = WEXITSTATUS(sp->sc_exit); in cleanutx()
508 if (sp->sc_utid != NULL) in cleanutx()
509 (void) memcpy(up->ut_id, sp->sc_utid, in cleanutx()
535 account(struct sactab *sp, pid_t pid) in account() argument
541 (void) strncpy(up->ut_user, sp->sc_tag, sizeof (up->ut_user)); in account()
551 (void) memset(sp->sc_utid, '\0', IDLEN); in account()
553 (void) memcpy(sp->sc_utid, up->ut_id, IDLEN); in account()
568 startit(struct sactab *sp) in startit() argument
583 if (chdir(sp->sc_tag) < 0) { in startit()
586 HOME, sp->sc_tag); in startit()
604 sp->sc_tag); in startit()
610 sp->sc_tag, ret); in startit()
620 if (sp->sc_lstate == NOTRUNNING) in startit()
622 (sp->sc_flags & D_FLAG) ? "disabled" : "enabled"); in startit()
625 (sp->sc_lstate == DISABLED) ? "disabled" : "enabled"); in startit()
629 sp->sc_tag); in startit()
633 (void) sprintf(pmtag, "PMTAG=%s", sp->sc_tag); in startit()
637 sp->sc_tag); in startit()
646 argvp = mkargv(sp); in startit()
648 (void) sprintf(Scratch, "starting port monitor <%s>", sp->sc_tag); in startit()
659 (void) sprintf(Scratch, "exec of port monitor <%s> failed", sp->sc_tag); in startit()
680 mkargv(struct sactab *sp) in mkargv() argument
683 char *p = sp->sc_cmd; /* working pointer */ in mkargv()
721 sp->sc_tag); in mkargv()
769 struct sactab *sp; /* working pointer */ in pollpms() local
775 for (sp = Sactab; sp; sp = sp->sc_next) { in pollpms()
776 if (sp->sc_pstate == NOTRUNNING || sp->sc_pstate == FAILED) { in pollpms()
780 if (sp->sc_ok == 0) { in pollpms()
782 pollfail(sp, RESP); in pollpms()
791 if (sp->sc_sstate == sp->sc_pstate) { in pollpms()
795 switch (sp->sc_sstate) { in pollpms()
823 sendpmmsg(sp, &sacmsg); in pollpms()
824 sp->sc_ok = 0; in pollpms()
839 struct sactab *sp; /* working pointer */ in reap() local
844 for (sp = Sactab; sp; sp = sp->sc_next) { in reap()
845 if (sp->sc_pid == pid) in reap()
848 if (sp == NULL) { in reap()
852 sp->sc_exit = status; in reap()
854 if (sp->sc_pstate != NOTRUNNING && sp->sc_pstate != FAILED) in reap()
855 pollfail(sp, DEATH); in reap()
869 pollfail(struct sactab *sp, int reason) in pollfail() argument
881 cleanutx(sp); in pollfail()
883 if (sp->sc_pstate == STOPPING) { in pollfail()
884 (void) sprintf(buf, "<%s> has stopped", sp->sc_tag); in pollfail()
886 sp->sc_pstate = NOTRUNNING; in pollfail()
887 sp->sc_lstate = NOTRUNNING; in pollfail()
888 (void) close(sp->sc_fd); in pollfail()
903 (void) sendsig(sp, SIGKILL); in pollfail()
904 if (sp->sc_rscnt < sp->sc_rsmax) { in pollfail()
909 sp->sc_tag); in pollfail()
913 sp->sc_tag); in pollfail()
915 sp->sc_rscnt++; in pollfail()
916 (void) close(sp->sc_fd); in pollfail()
917 (void) startpm(sp); in pollfail()
919 sp->sc_sstate = sp->sc_pstate = FAILED; in pollfail()
920 (void) close(sp->sc_fd); in pollfail()
921 (void) sprintf(buf, "<%s> has FAILED", sp->sc_tag); in pollfail()
939 struct sactab *sp; /* working pointer */ in readpipe() local
993 sp = findpm(pp->pm_tag); in readpipe()
994 if (sp == NULL) { in readpipe()
1002 sp->sc_tag); in readpipe()
1014 sp->sc_tag); in readpipe()
1017 if (sp->sc_sstate == sp->sc_pstate) { in readpipe()
1019 if (sp->sc_sstate == UNKNOWN) { in readpipe()
1021 sp->sc_sstate = pp->pm_state; in readpipe()
1022 sp->sc_pstate = pp->pm_state; in readpipe()
1026 sp->sc_lstate = pp->pm_state; in readpipe()
1028 if (pp->pm_state != sp->sc_pstate) { in readpipe()
1034 sp->sc_pstate = pp->pm_state; in readpipe()
1036 } else if (sp->sc_sstate == pp->pm_state) { in readpipe()
1040 sp->sc_tag, pstate(sp->sc_pstate), in readpipe()
1043 sp->sc_pstate = pp->pm_state; in readpipe()
1044 } else if (sp->sc_pstate != pp->pm_state) { in readpipe()
1051 if (sp->sc_pstate != STOPPING) in readpipe()
1052 sp->sc_pstate = pp->pm_state; in readpipe()
1058 sp->sc_tag); in readpipe()
1063 sp->sc_ok = 1; in readpipe()
1065 sp->sc_maxclass = pp->pm_maxclass; in readpipe()