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

Function sys_getsid

components/lwp/lwp_session.c:348–377  ·  view source on GitHub ↗

* getsid() returns the session ID of the process with process ID pid. * If pid is 0, getsid() returns the session ID of the calling process. */

Source from the content-addressed store, hash-verified

346 * If pid is 0, getsid() returns the session ID of the calling process.
347 */
348sysret_t sys_getsid(pid_t pid)
349{
350 rt_lwp_t process, self_process;
351 pid_t sid;
352
353 lwp_pid_lock_take();
354 process = lwp_from_pid_locked(pid);
355 lwp_pid_lock_release();
356
357 if (process == RT_NULL)
358 {
359 return -ESRCH;
360 }
361
362 self_process = lwp_self();
363 sid = lwp_sid_get_byprocess(process);
364
365 if (sid != lwp_sid_get_byprocess(self_process))
366 {
367 /**
368 * A process with process ID pid exists, but it is not in the same session as the calling process,
369 * and the implementation considers this an error.
370 *
371 * Note: Linux does not return EPERM.
372 */
373 return -EPERM;
374 }
375
376 return sid;
377}
378
379#ifdef RT_USING_FINSH
380

Callers

nothing calls this directly

Calls 5

lwp_pid_lock_takeFunction · 0.85
lwp_from_pid_lockedFunction · 0.85
lwp_pid_lock_releaseFunction · 0.85
lwp_selfFunction · 0.85
lwp_sid_get_byprocessFunction · 0.85

Tested by

no test coverage detected