MCPcopy Create free account
hub / github.com/RT-Thread/rt-thread / lwp_jobctrl_on_exit

Function lwp_jobctrl_on_exit

components/lwp/lwp_jobctrl.c:44–86  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

42}
43
44void lwp_jobctrl_on_exit(struct rt_lwp *lwp)
45{
46 rt_processgroup_t pgrp;
47 rt_session_t session;
48 lwp_tty_t tp;
49
50 pgrp = lwp->pgrp;
51 RT_ASSERT(pgrp);
52 session = pgrp->session;
53 RT_ASSERT(session);
54
55 /**
56 * as a session leader, we have to mark tty as freed. So others can race to
57 * take it before we actually close and released that tty
58 */
59 SESS_LOCK(session);
60 if (session->sid == lwp->pid)
61 {
62 tp = session->ctty;
63 session->leader = 0;
64
65 /* signal to foreground group that modem is disconnected */
66 if (tp)
67 {
68 tty_lock(tp);
69 if (tp->t_session == session)
70 lwp_tty_signal_pgrp(tp, SIGHUP);
71 tty_unlock(tp);
72 }
73
74 /* revoke tty vnode ? */
75
76 rt_list_for_each_entry(pgrp, &session->processgroup, pgrp_list_node)
77 {
78 jobctrl_set_pgrp_orphaned(pgrp);
79 }
80
81 }
82 SESS_UNLOCK(session);
83
84 /* release tty */
85 /* allow tty stolen? */
86}

Callers 1

_resr_cleanupFunction · 0.85

Calls 2

lwp_tty_signal_pgrpFunction · 0.85

Tested by

no test coverage detected