| 84 | } |
| 85 | |
| 86 | int lwp_session_delete(rt_session_t session) |
| 87 | { |
| 88 | int retry = 1; |
| 89 | lwp_tty_t ctty; |
| 90 | |
| 91 | /* parameter check */ |
| 92 | if (session == RT_NULL) |
| 93 | { |
| 94 | return -EINVAL; |
| 95 | } |
| 96 | |
| 97 | /* clear children sid */ |
| 98 | lwp_session_update_children_info(session, 0); |
| 99 | |
| 100 | while (retry) |
| 101 | { |
| 102 | retry = 0; |
| 103 | ctty = session->ctty; |
| 104 | SESS_LOCK_NESTED(session); |
| 105 | |
| 106 | if (session->ctty == ctty) |
| 107 | { |
| 108 | if (ctty) |
| 109 | { |
| 110 | SESS_UNLOCK(session); |
| 111 | |
| 112 | /** |
| 113 | * Note: it's safe to release the session lock now. Even if someone |
| 114 | * race to acquire the tty, it's safe under protection of tty_lock() |
| 115 | * and the check inside |
| 116 | */ |
| 117 | tty_lock(ctty); |
| 118 | tty_rel_sess(ctty, session); |
| 119 | session->ctty = RT_NULL; |
| 120 | } |
| 121 | else |
| 122 | { |
| 123 | SESS_UNLOCK(session); |
| 124 | } |
| 125 | } |
| 126 | else |
| 127 | { |
| 128 | SESS_UNLOCK(session); |
| 129 | retry = 1; |
| 130 | } |
| 131 | } |
| 132 | |
| 133 | rt_object_detach(&(session->object)); |
| 134 | rt_mutex_detach(&(session->mutex)); |
| 135 | rt_free(session); |
| 136 | |
| 137 | return 0; |
| 138 | } |
| 139 | |
| 140 | int lwp_session_insert(rt_session_t session, rt_processgroup_t group) |
| 141 | { |
no test coverage detected