| 503 | #include "finsh.h" |
| 504 | |
| 505 | long list_processgroup(void) |
| 506 | { |
| 507 | int count = 0, index; |
| 508 | rt_processgroup_t *groups; |
| 509 | rt_processgroup_t group; |
| 510 | rt_thread_t thread; |
| 511 | char name[RT_NAME_MAX]; |
| 512 | |
| 513 | rt_kprintf("PGID SID leader process\n"); |
| 514 | rt_kprintf("---- ---- ----------------\n"); |
| 515 | |
| 516 | count = rt_object_get_length(RT_Object_Class_ProcessGroup); |
| 517 | if (count > 0) |
| 518 | { |
| 519 | /* get pointers */ |
| 520 | groups = (rt_processgroup_t *)rt_calloc(count, sizeof(rt_processgroup_t)); |
| 521 | if (groups) |
| 522 | { |
| 523 | index = rt_object_get_pointers(RT_Object_Class_ProcessGroup, (rt_object_t *)groups, count); |
| 524 | if (index > 0) |
| 525 | { |
| 526 | for (index = 0; index < count; index++) |
| 527 | { |
| 528 | struct rt_processgroup pgrp; |
| 529 | group = groups[index]; |
| 530 | PGRP_LOCK(group); |
| 531 | rt_memcpy(&pgrp, group, sizeof(struct rt_processgroup)); |
| 532 | PGRP_UNLOCK(group); |
| 533 | |
| 534 | if (pgrp.leader) |
| 535 | { |
| 536 | thread = rt_list_entry(pgrp.leader->t_grp.prev, struct rt_thread, sibling); |
| 537 | rt_strncpy(name, thread->parent.name, RT_NAME_MAX); |
| 538 | } |
| 539 | else |
| 540 | { |
| 541 | rt_strncpy(name, "nil", RT_NAME_MAX); |
| 542 | } |
| 543 | |
| 544 | rt_kprintf("%4d %4d %-*.*s\n", pgrp.pgid, pgrp.sid, RT_NAME_MAX, RT_NAME_MAX, name); |
| 545 | } |
| 546 | } |
| 547 | rt_free(groups); |
| 548 | } |
| 549 | } |
| 550 | |
| 551 | return 0; |
| 552 | } |
| 553 | MSH_CMD_EXPORT(list_processgroup, list process group); |
| 554 | #endif |
nothing calls this directly
no test coverage detected