Xfennec / progress

Linux tool to show progress for cp, mv, dd, ... (formerly known as cv)
GNU General Public License v3.0
8.57k stars 313 forks source link

Add flag -t to adjust max pid count #163

Open vgmoose opened 3 years ago

vgmoose commented 3 years ago

This is for the issue in #146 with the process count limit being hit. This PR defaults to 32 and lets the user supply their own value.

I'm unsure of the implications of making old_results no longer static, but changing it allows the user-supplied variable to be used instead.

Usage:

./progress -t 64

Another solution might be to scan for the processes first to get an upper count, before going on to fill the array with the process info, to not need a count supplied with >32 processes.

Xfennec commented 1 year ago

I added this PR on my todo list… and never got time to unstack it. Sorry for that!

The issue with the current patch is that removing the static nature of old_results may compromise the watch feature (we need persistent memory between each copy_and_clean_results() call).

It currently sort of works because the compiler does not reallocate between call, but it's an happy accident :sweat_smile: .

Making old_results global and allocate on startup would be a quick and dirty fix for this, I guess.