View previous topic :: View next topic |
Author |
Message |
apurkrt Tux's lil' helper
Joined: 26 Feb 2011 Posts: 116 Location: Czechia, Europe
|
Posted: Sat Apr 25, 2020 5:18 pm Post subject: How to gracefully stop emerge? (not ctrl-c) |
|
|
Hi, I may have missed something, but: how to gracefully stop a running emerge?
ctrl-c is what I usually do - but that's not graceful.
If emerge is interrupted during the "merge" phase, there could be incomplete merge, possibly rendering the merged package in non-working condition.
With higher "--jobs N" there is higher chance of of this to happen.
I found this old thread here
https://forums.gentoo.org/viewtopic-t-511398-start-0.html
there is no real solution to this question.
So I'd like to bring it up again.
I'd suggest something like "touch /run/stop-emerge" could work as a semaphore. Possibly stoping after the compile phase. Sure there could be way how to differentiate (possible) multiple emerges. |
|
Back to top |
|
|
alamahant Advocate
Joined: 23 Mar 2019 Posts: 3916
|
Posted: Sat Apr 25, 2020 5:38 pm Post subject: |
|
|
Open another terminal and run
Code: |
kill -TERM $(ps -ef | grep emerge | grep -v colour | awk '{ print $2 }')
|
|
|
Back to top |
|
|
Hu Administrator
Joined: 06 Mar 2007 Posts: 22589
|
Posted: Sat Apr 25, 2020 6:43 pm Post subject: |
|
|
That ps could be simplified and made safer: Code: | ps -C emerge -o pid= | No need for grep or awk. Also, if you did need to post-process the output for filtering, awk could do that and avoid the need for grep.
I'm not sure that using kill is much better though, because the user may have arranged for the termination of emerge to automatically terminate its children. It would be better to provide the mechanism that OP requested, where Portage can notice a stop request and gracefully stop itself at a good time. |
|
Back to top |
|
|
Ant P. Watchman
Joined: 18 Apr 2009 Posts: 6920
|
Posted: Sat Apr 25, 2020 7:56 pm Post subject: |
|
|
Move $DISTDIR out of the way, make it a symlink to /dev/null, then wait for emerge to give up when it can't start new jobs. |
|
Back to top |
|
|
Hu Administrator
Joined: 06 Mar 2007 Posts: 22589
|
Posted: Sat Apr 25, 2020 9:34 pm Post subject: |
|
|
That's an interesting solution. As a less disruptive form, you could mount an empty zero-sized tmpfs over $DISTDIR with mount -t tmpfs -o nr_inodes=1,ro $DISTDIR $DISTDIR. This leaves the directory untouched, but hidden, so the change is automatically lost on reboot. |
|
Back to top |
|
|
Ant P. Watchman
Joined: 18 Apr 2009 Posts: 6920
|
Posted: Sat Apr 25, 2020 11:28 pm Post subject: |
|
|
Oh, that's a much better trick, never would've thought of that. |
|
Back to top |
|
|
mike155 Advocate
Joined: 17 Sep 2010 Posts: 4438 Location: Frankfurt, Germany
|
Posted: Sat Apr 25, 2020 11:44 pm Post subject: |
|
|
Quote: | ctrl-c is what I usually do - but that's not graceful. |
I really hope that emerge blocks SIGINT (Ctrl-C) before it starts operations that must not be interrupted. |
|
Back to top |
|
|
fpemud Guru
Joined: 15 Feb 2012 Posts: 350
|
Posted: Sun Apr 26, 2020 1:23 am Post subject: |
|
|
I think the ultimate solution would be making the emerge process transactional.
Perhaps utilizing the lvm or btrfs snapshot. |
|
Back to top |
|
|
apurkrt Tux's lil' helper
Joined: 26 Feb 2011 Posts: 116 Location: Czechia, Europe
|
Posted: Sun Apr 26, 2020 8:25 am Post subject: |
|
|
Just tested that none of HUP, INT nor TERM stops gracefully - they all can stop emerge in the middle of ">>> Installing ..." phase (which is what I'm worried about the most). |
|
Back to top |
|
|
xaviermiller Bodhisattva
Joined: 23 Jul 2004 Posts: 8717 Location: ~Brussels - Belgique
|
Posted: Mon Apr 27, 2020 7:16 am Post subject: |
|
|
Hi,
You can try a trick on the /etc/portage/bashrc file and add some hook at the place you want _________________ Kind regards,
Xavier Miller |
|
Back to top |
|
|
apurkrt Tux's lil' helper
Joined: 26 Feb 2011 Posts: 116 Location: Czechia, Europe
|
Posted: Mon Apr 27, 2020 7:25 am Post subject: |
|
|
xaviermiller wrote: | Hi,
You can try a trick on the /etc/portage/bashrc file and add some hook at the place you want |
Now that seems like a nudge in the right direction. Thanks a lot, xaviermiller! |
|
Back to top |
|
|
toralf Developer
Joined: 01 Feb 2004 Posts: 3938 Location: Hamburg
|
Posted: Wed Aug 16, 2023 8:01 pm Post subject: |
|
|
I'm playing now with sth like this in bashrc: Code: | case ${EBUILD_PHASE} in
clean|setup|unpack|prepare|configure|compile|test) exit 1 ;;
esac
| . |
|
Back to top |
|
|
|