Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 37960 - Misc. exit functions fixes
Summary: Misc. exit functions fixes
Status: RESOLVED FIXED
Alias: None
Product: Portage Development
Classification: Unclassified
Component: Core (show other bugs)
Hardware: All Linux
: High minor (vote)
Assignee: Portage team
URL:
Whiteboard:
Keywords: InVCS
Depends on:
Blocks:
 
Reported: 2004-01-12 05:36 UTC by TGL
Modified: 2004-02-08 17:55 UTC (History)
0 users

See Also:
Package list:
Runtime testing required: ---


Attachments
ebuild.sh--tee_log.fix (ebuild.sh--log-fixes.patch,712 bytes, patch)
2004-01-12 05:38 UTC, TGL
Details | Diff
portage.py--wait_for_childs.patch (wait-for-childs.patch,483 bytes, patch)
2004-01-12 05:41 UTC, TGL
Details | Diff
emerge--atexit.patch (atexit-fix.patch,628 bytes, patch)
2004-01-12 05:43 UTC, TGL
Details | Diff
ebuild.sh--log-fixes.patch (ebuild.sh--log-fixes.patch,585 bytes, patch)
2004-01-18 10:05 UTC, TGL
Details | Diff
portage.py--wait-for-children.patch (wait-for-children.patch,383 bytes, patch)
2004-01-22 06:23 UTC, TGL
Details | Diff
emerge--atexit.patch (atexit-fix.patch,693 bytes, patch)
2004-02-03 10:03 UTC, TGL
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description TGL 2004-01-12 05:36:42 UTC
Here are three small patches that fixes various issues in exiting / signal handling. This are all minor bugs, that have really bad effects, but it can't hurt to fix them... 

Patches are against 2.0.50_pre12.


Reproducible: Always
Steps to Reproduce:
Comment 1 TGL 2004-01-12 05:38:53 UTC
Created attachment 23674 [details, diff]
ebuild.sh--tee_log.fix

This one fixes two small problems with the way recursion for per-ebuild logging
is done:

 - first, the code seems to assume that $? will be the status of the recursive
call (and then delete the success file if non-zero), but it is in fact the
status of the last pipe command, "tee...", which always return 0. It has no
wrong effect tho because it never happens that there is a success file whereas
the exit status of the recursive call is non-zero.


 - second, when you don't use per-ebuild logging and Ctrl-C a build process,
you get something like this:

< snip some make commands >
Caught signal 2
make[2]: *** Deleting file `date_parser.o'
make[2]: *** Deleting file `context_menus.o'
make[2]: *** [date_parser.o] Interrupt
make[2]: *** [context_menus.o] Interrupt
make[1]: *** [all-recursive] Interrupt
make: *** [all] Interrupt
 
/usr/portage/app-pda/gtkpod/gtkpod-0.60.ebuild: src_compile aborted; exiting.
 
root %

But with per-ebuild logging, you miss this messages, because the '| tee ...'
dies too fast. I've added a SIGINT/SIGQUIT handler to the '| tee' process so
that it don't die on user interrupt, but only once the recursive call has
really exited.
Comment 2 TGL 2004-01-12 05:41:26 UTC
Created attachment 23675 [details, diff]
portage.py--wait_for_childs.patch

Again with the previous "Ctrl-C during build" test, you will sometimes get this
output:
< snip some make commands >
Caught signal 2
make[2]: *** Deleting file `date_parser.o'
make[2]: *** Deleting file `context_menus.o'
make[2]: *** [date_parser.o] Interrupt
root % make[2]: *** [context_menus.o] Interrupt
make[1]: *** [all-recursive] Interrupt
make: *** [all] Interrupt
 
/usr/portage/app-pda/gtkpod/gtkpod-0.60.ebuild: src_compile aborted; exiting.
 
The "root %" prompt lost before the end of messages is here because emerge, the
foreground process, exits before the spawned ebuild.sh. I think this is not a
good thing: if a spawned process refuses to die on SIGINT for instance, the
user won't notice it and will probably keep this process lost in the
background. 
This patch makes portage exit function to wait for child process if any, thus
solves this.
Comment 3 TGL 2004-01-12 05:43:33 UTC
Created attachment 23676 [details, diff]
emerge--atexit.patch

I think there is a missunderstanding of "atexit" in emerge code: registering a
function adds it to the stack of functions to execute on exit, but does _not_
remove the previously registered function as it is written in comments (or
maybe this was true in some previous python versions?). 

Like it is now, when emerge exits, portageexit() is called twice: once because
it is registered, and once by emergeexit(). And when an emerge is cancelled by
a SIGINT, emergeexit() is called twice because of the SIGINT handler code (this
one, you can see it in emerge.log: the "Terminating" message is duplicated),
and thus portageexit() three times. 

The patch removes manual calls to portageexit().
Comment 4 TGL 2004-01-12 05:45:34 UTC
In comment #O, I've wrote:
> This are all minor bugs, that have really bad effects

It must read: 
This are all minor bugs, that have _no_ really bad effects :)
Comment 5 TGL 2004-01-18 10:05:37 UTC
Created attachment 24031 [details, diff]
ebuild.sh--log-fixes.patch

For the "tee dies too fast on Ctrl-C" problem, there is in fact an option that
does exactly what was needed :) 
So here is a version of the patch without the SIGINT trap, but with a "-i"
instead. Much simpler.
Comment 6 TGL 2004-01-22 06:23:44 UTC
Created attachment 24233 [details, diff]
portage.py--wait-for-children.patch

Sorry, the previous patch was not diffed against a vanilla portage. This one
is, and should apply correctly on 2.0.50_pre19.
Comment 7 TGL 2004-02-03 10:03:38 UTC
Created attachment 24894 [details, diff]
emerge--atexit.patch

I've also noticed that there are some other "*** terminating" messages in
emerge.log that doesn't correspond to any "Starting emrge...". They come from
--pretend mode. Since there are no other log message in this mode, i've added
to this patch a test to remove also this one.
Comment 8 Marius Mauch (RETIRED) gentoo-dev 2004-02-08 17:55:25 UTC
supposed to be fixed in 2.0.50 which is stable now. If this bug is not fixed please reopen.