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

Function list_session

components/lwp/lwp_session.c:383–430  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

381#include "finsh.h"
382
383long list_session(void)
384{
385 int count = 0, index;
386 rt_session_t *sessions;
387 rt_session_t session;
388 rt_thread_t thread;
389 char name[RT_NAME_MAX];
390
391 rt_kprintf("SID leader process\n");
392 rt_kprintf("---- ----------------\n");
393
394 count = rt_object_get_length(RT_Object_Class_Session);
395 if (count > 0)
396 {
397 /* get pointers */
398 sessions = (rt_session_t *)rt_calloc(count, sizeof(rt_session_t));
399 if (sessions)
400 {
401 index = rt_object_get_pointers(RT_Object_Class_Session, (rt_object_t *)sessions, count);
402 if (index > 0)
403 {
404 for (index = 0; index < count; index++)
405 {
406 struct rt_session se;
407 session = sessions[index];
408 SESS_LOCK(session);
409 rt_memcpy(&se, session, sizeof(struct rt_session));
410 SESS_UNLOCK(session);
411
412 if (se.leader && se.leader)
413 {
414 thread = rt_list_entry(se.leader->t_grp.prev, struct rt_thread, sibling);
415 rt_strncpy(name, thread->parent.name, RT_NAME_MAX);
416 }
417 else
418 {
419 rt_strncpy(name, "nil", RT_NAME_MAX);
420 }
421
422 rt_kprintf("%4d %-*.*s\n", se.sid, RT_NAME_MAX, RT_NAME_MAX, name);
423 }
424 }
425 rt_free(sessions);
426 }
427 }
428
429 return 0;
430}
431MSH_CMD_EXPORT(list_session, list session);
432#endif

Callers

nothing calls this directly

Calls 7

rt_kprintfFunction · 0.85
rt_object_get_lengthFunction · 0.85
rt_callocFunction · 0.85
rt_object_get_pointersFunction · 0.85
rt_memcpyFunction · 0.85
rt_strncpyFunction · 0.85
rt_freeFunction · 0.85

Tested by

no test coverage detected