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

New: option -g extend watch to process group #122

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

step-
Copy link

@step- step- commented Nov 11, 2018

This is a new feature
progress -g -p <pid> will show the current progress of <pid> and all the processes (max 32 compile-time constant) that are in <pid>'s process group (ps -o pgrp). And progress -m -g -p <pid> will monitor the group till <pid> exits. This can be useful when monitoring shell scripts that copy data using several basic commands, e.g.,

./script & xterm -e progress -m -g -p $! & wait     # from command line
xterm -e progress -m -g -p $$ &     # from inside the script

The second line above can be added inside any script that monitors its own copy progress.

Note: Implemented for Linux only. The __APPLE__ define branch has a stub.

So `progress -g -p <pid>` will show the current progress of <pid> and
all the processes (max 32 compile-time constant) that are in <pid>'s
process group (ps -o pgrp). And `progress -m -g -p <pid>` will monitor
the group till <pid> exits. This can be useful when monitoring shell
scripts that copy data using several basic commands, e.g.,

    ./script & progress -m -g -p $!
    ./script & xterm -e progress -m -g -p $! & wait

Note: Implemented for Linux only. The `__APPLE__` define branch has a
stub.
@Xfennec
Copy link
Owner

Xfennec commented Nov 13, 2018

Great idea, this is a nice addition to the project. I would like to see an OSX implementation before merging this, but I'm not excluding to merge it anyway if no contribution land on this subject.

@step-
Copy link
Author

step- commented Nov 14, 2018

I'm glad you like it. I am unable to implement it for OSX. I have no Apple hardware and no experience of OSX, sorry.

@step-
Copy link
Author

step- commented Nov 16, 2018

A note about working around a common situation that prevents using -g. Let me describe.

If you write a script that includes
monitor -m -g -p $$

meaning, show all activity for the script's process group, and you run the script from the command line, progress will indeed monitor what you intended.

However, if you run the script by clicking its icon in a file manager, progress will most likely fail complaining that it can't monitor more than 32 processes. This is because when you start the script from a file manager icon, the script's process group is the window manager's process group, which contains all other GUI applications.

The work-around involves writing the script so that it takes its own process group when it's started from the GUI instead of from a terminal.

However, after reading some google links: [1] [2] [3], my conclusion is that a general work-around that covers all cases and runs from within the script doesn't exist. So each work-around needs to be specific to the script and the use case.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants