Add group ID or parent PID to procfs output (if available)
This commit is contained in:
parent
96f57eb0d9
commit
1c8216a6ce
|
@ -72,6 +72,18 @@
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Pre-processor Definitions
|
* Pre-processor Definitions
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
/* See include/nuttx/sched.h: */
|
||||||
|
|
||||||
|
#undef HAVE_GROUPID
|
||||||
|
|
||||||
|
#if defined(CONFIG_SCHED_HAVE_PARENT) && defined(CONFIG_SCHED_CHILD_STATUS)
|
||||||
|
# define HAVE_GROUPID 1
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef CONFIG_DISABLE_PTHREAD
|
||||||
|
# undef HAVE_GROUPID
|
||||||
|
#endif
|
||||||
|
|
||||||
/* Determines the size of an intermediate buffer that must be large enough
|
/* Determines the size of an intermediate buffer that must be large enough
|
||||||
* to handle the longest line generated by this logic.
|
* to handle the longest line generated by this logic.
|
||||||
*/
|
*/
|
||||||
|
@ -362,6 +374,8 @@ static FAR const struct proc_node_s *proc_findnode(FAR const char *relpath)
|
||||||
* 123456789012345678901234567890
|
* 123456789012345678901234567890
|
||||||
* Name: xxxx... Task/thread name (See CONFIG_TASK_NAME_SIZE)
|
* Name: xxxx... Task/thread name (See CONFIG_TASK_NAME_SIZE)
|
||||||
* Type: xxxxxxx {Task, pthread, Kthread, Invalid}
|
* Type: xxxxxxx {Task, pthread, Kthread, Invalid}
|
||||||
|
* PPID: xxxxx Parent thread ID
|
||||||
|
* Group: xxxxx Group ID
|
||||||
* State: xxxxxxxx,xxxxxxxxx {Invalid, Waiting, Ready, Running, Inactive},
|
* State: xxxxxxxx,xxxxxxxxx {Invalid, Waiting, Ready, Running, Inactive},
|
||||||
* {Unlock, Semaphore, Signal, MQ empty, MQ full}
|
* {Unlock, Semaphore, Signal, MQ empty, MQ full}
|
||||||
* Flags: xxx N,P,X
|
* Flags: xxx N,P,X
|
||||||
|
@ -375,6 +389,9 @@ static ssize_t proc_status(FAR struct proc_file_s *procfile,
|
||||||
FAR struct tcb_s *tcb, FAR char *buffer,
|
FAR struct tcb_s *tcb, FAR char *buffer,
|
||||||
size_t buflen, off_t offset)
|
size_t buflen, off_t offset)
|
||||||
{
|
{
|
||||||
|
#ifdef HAVE_GROUPID
|
||||||
|
FAR struct task_group_s *group;
|
||||||
|
#endif
|
||||||
FAR const char *policy;
|
FAR const char *policy;
|
||||||
FAR const char *name;
|
FAR const char *name;
|
||||||
size_t remaining;
|
size_t remaining;
|
||||||
|
@ -421,6 +438,30 @@ static ssize_t proc_status(FAR struct proc_file_s *procfile,
|
||||||
return totalsize;
|
return totalsize;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef CONFIG_SCHED_HAVE_PARENT
|
||||||
|
#ifdef HAVE_GROUPID
|
||||||
|
group = tcb->group;
|
||||||
|
DEBUGASSERT(group);
|
||||||
|
|
||||||
|
linesize = snprintf(procfile->line, STATUS_LINELEN, "%-12s%d\n", "Group:",
|
||||||
|
group->tg_pgid);
|
||||||
|
#else
|
||||||
|
linesize = snprintf(procfile->line, STATUS_LINELEN, "%-12s%d\n", "PPID:",
|
||||||
|
tcb->ppid);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
copysize = procfs_memcpy(procfile->line, linesize, buffer, remaining, &offset);
|
||||||
|
|
||||||
|
totalsize += copysize;
|
||||||
|
buffer += copysize;
|
||||||
|
remaining -= copysize;
|
||||||
|
|
||||||
|
if (totalsize >= buflen)
|
||||||
|
{
|
||||||
|
return totalsize;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
/* Show the thread state */
|
/* Show the thread state */
|
||||||
|
|
||||||
linesize = snprintf(procfile->line, STATUS_LINELEN, "%-12s%s\n", "State:",
|
linesize = snprintf(procfile->line, STATUS_LINELEN, "%-12s%s\n", "State:",
|
||||||
|
|
Loading…
Reference in New Issue