MCPcopy Create free account
hub / github.com/F-Stack/f-stack / killjobc

Function killjobc

freebsd/kern/kern_proc.c:872–930  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

870}
871
872void
873killjobc(void)
874{
875 struct session *sp;
876 struct tty *tp;
877 struct proc *p;
878 struct vnode *ttyvp;
879
880 p = curproc;
881 MPASS(p->p_flag & P_WEXIT);
882 sx_assert(&proctree_lock, SX_LOCKED);
883
884 if (SESS_LEADER(p)) {
885 sp = p->p_session;
886
887 /*
888 * s_ttyp is not zero'd; we use this to indicate that
889 * the session once had a controlling terminal. (for
890 * logging and informational purposes)
891 */
892 SESS_LOCK(sp);
893 ttyvp = sp->s_ttyvp;
894 tp = sp->s_ttyp;
895 sp->s_ttyvp = NULL;
896 sp->s_ttydp = NULL;
897 sp->s_leader = NULL;
898 SESS_UNLOCK(sp);
899
900 /*
901 * Signal foreground pgrp and revoke access to
902 * controlling terminal if it has not been revoked
903 * already.
904 *
905 * Because the TTY may have been revoked in the mean
906 * time and could already have a new session associated
907 * with it, make sure we don't send a SIGHUP to a
908 * foreground process group that does not belong to this
909 * session.
910 */
911
912 if (tp != NULL) {
913 tty_lock(tp);
914 if (tp->t_session == sp)
915 tty_signal_pgrp(tp, SIGHUP);
916 tty_unlock(tp);
917 }
918
919 if (ttyvp != NULL) {
920 sx_xunlock(&proctree_lock);
921 if (vn_lock(ttyvp, LK_EXCLUSIVE) == 0) {
922 VOP_REVOKE(ttyvp, REVOKEALL);
923 VOP_UNLOCK(ttyvp);
924 }
925 devfs_ctty_unref(ttyvp);
926 sx_xlock(&proctree_lock);
927 }
928 }
929 fixjobc_kill(p);

Callers 1

exit1Function · 0.85

Calls 3

tty_signal_pgrpFunction · 0.85
vn_lockFunction · 0.85
fixjobc_killFunction · 0.85

Tested by

no test coverage detected