MCPcopy Index your code
hub / github.com/RT-Thread/rt-thread / lwp_pgrp_delete

Function lwp_pgrp_delete

components/lwp/lwp_pgrp.c:120–177  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

118#include <terminal/terminal.h>
119
120int lwp_pgrp_delete(rt_processgroup_t group)
121{
122 int retry = 1;
123 rt_session_t session = RT_NULL;
124 int is_session_free = 0;
125 lwp_tty_t ctty;
126
127 /* parameter check */
128 if (group == RT_NULL)
129 {
130 return -EINVAL;
131 }
132
133 LOG_I("delete(ptr:%p, pgid:%d)() by pid:%d", group, group->pgid, lwp_getpid());
134
135 while (retry)
136 {
137 retry = 0;
138 session = lwp_session_find(lwp_sid_get_bypgrp(group));
139 if (session)
140 {
141 ctty = session->ctty;
142 if (ctty)
143 {
144 /**
145 * Note: it's safe to release pgrp even we do this multiple,
146 * the neccessary check is done before the tty actually detach
147 */
148 tty_lock(ctty);
149 tty_rel_pgrp(ctty, group); // tty_unlock
150 }
151
152 SESS_LOCK(session);
153 PGRP_LOCK_NESTED(group);
154 if (group->session == session && session->ctty == ctty)
155 {
156 rt_object_detach(&(group->object));
157 is_session_free = lwp_session_remove(session, group);
158 }
159 else
160 {
161 retry = 1;
162
163 }
164
165 PGRP_UNLOCK(group);
166 if (is_session_free != 1)
167 SESS_UNLOCK(session);
168 }
169 else
170 {
171 rt_object_detach(&(group->object));
172 }
173 }
174
175 lwp_pgrp_dec_ref(group);
176 return 0;
177}

Callers 2

sys_setsidFunction · 0.85
lwp_pgrp_removeFunction · 0.85

Calls 7

lwp_getpidFunction · 0.85
lwp_session_findFunction · 0.85
lwp_sid_get_bypgrpFunction · 0.85
tty_rel_pgrpFunction · 0.85
rt_object_detachFunction · 0.85
lwp_session_removeFunction · 0.85
lwp_pgrp_dec_refFunction · 0.85

Tested by

no test coverage detected