Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add long option to pstree to prevent truncating #228

Merged
merged 1 commit into from
Jun 21, 2023

Conversation

miguelgila
Copy link
Contributor

Hi,

I've noticed when there are a lot of levels of nested children processes/threads, the output of pstree -A -p %ld | tr \\- \\\\n doesn't always include the pids of all the children processes, as the output of pstree is truncated to 132 characters (the default). A workaround this limitation is to include the flag -l in the call to pstree, which avoids truncating altogether.

Alternatively, the default column where it starts truncating could be increased, but I think this workaround is cleaner.

What do you think?

Thanks,
Miguel

@graeme-a-stewart graeme-a-stewart self-requested a review June 14, 2023 12:38
@graeme-a-stewart graeme-a-stewart added the bug Something isn't working label Jun 14, 2023
@graeme-a-stewart
Copy link
Member

Hello @miguelgila - thanks very much for the patch. It looks fine to me.

OTOH, this older pstree method for finding all of the child PIDs is quite deprecated. Even the venerable CentOS7 kernel supports the task children attributes in /proc (see

bool kernel_proc_pid_test(const pid_t pid) {
).

Which system were you using that you came across this issue?

I don't mind accepting the patch, but likely we shall remove this support for very old kernels at some point.

@graeme-a-stewart graeme-a-stewart merged commit fd32223 into HSF:main Jun 21, 2023
@graeme-a-stewart
Copy link
Member

P.S. Apologies for sitting on this for so long. The email/alert from GitHub was overlooked and I just didn't see this for ages.

@miguelgila miguelgila deleted the pstree-long branch June 21, 2023 13:44
@miguelgila
Copy link
Contributor Author

Hi @graeme-a-stewart, thanks for accepting the patch. We are running this on a version of SLE 15 SP3 where I can't find the task children attributes. I can't say if it's because the upstream kernel doesn't have that capability, or because ours (provided by HPE) is modified and doesn't.

@graeme-a-stewart
Copy link
Member

Thanks @miguelgila - that's very interesting. So it's not to do with the age of the kernel, but also on some feature set that is exposed to user space. Then we won't deprecate this code ever, but we keep it for just such runtime environments.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants