Bug 40857

Summary: pstree output cannot be redirected to a file
Product: Sisyphus Reporter: Ivan A. Melnikov <iv>
Component: psmiscAssignee: Vitaly Chikunov <vt>
Status: CLOSED FIXED QA Contact: qa-sisyphus
Severity: normal    
Priority: P5 CC: ldv, vseleznv, vt
Version: unstable   
Hardware: x86_64   
OS: Linux   
See Also: https://bugzilla.altlinux.org/show_bug.cgi?id=41600

Description Ivan A. Melnikov 2021-09-04 09:57:46 MSK
While trying to save `pstree -ap` output to a file and I'm getting a really strange error:

$ pstree -ap > pstree.txt
File size limit exceeded

Of course, I don't have any filesize limit on this system:

$ ulimit -f
unlimited

It turns out that pstree itself sets the filesize limit -- probably in some kind of a sandboxing effort:

$ strace -e /limit pstree -ap > /dev/null
prlimit64(0, RLIMIT_NPROC, {rlim_cur=0, rlim_max=0}, NULL) = 0
prlimit64(0, RLIMIT_FSIZE, {rlim_cur=0, rlim_max=0}, NULL) = 0
prlimit64(0, RLIMIT_NOFILE, {rlim_cur=0, rlim_max=0}, NULL) = 0
+++ exited with 0 +++

So, obvious workaround like intermediate `cat` works:

$ pstree -ap | cat > pstree.txt
$ echo $?
0
$ wc pstree.txt
  578  2120 22017 pstree.txt

But, well, such limitation on where output can go definitely looks like a bug to me.
Comment 1 Repository Robot 2021-09-04 12:17:13 MSK
psmisc-23.3-alt3 -> sisyphus:

 Sat Sep 04 2021 Vitaly Chikunov <vt@altlinux> 23.3-alt3
 - Fix output redirect (closes: #40857).
Comment 2 Vitaly Chikunov 2021-12-21 04:59:08 MSK
*** Bug 41600 has been marked as a duplicate of this bug. ***