[pacman-dev] Strange cleanup() function usage in pacman.c
Cleanup() is a signal handler. However, we usually pass some return values to it manually, see lines 816 and 822 for example. Or run pacman -V --debug. (parseargs returns with 2 == SIGINT) Is this OK?
On Sun, Mar 09, 2008 at 11:40:48AM +0100, Nagy Gabor wrote:
Cleanup() is a signal handler. However, we usually pass some return values to it manually, see lines 816 and 822 for example. Or run pacman -V --debug. (parseargs returns with 2 == SIGINT) Is this OK?
Huh yes, all these cleanup calls don't look right.. Well, we only listen to SIGINT 2, SIGTERM 15 and SIGSEGV 11, but still we shouldn't call cleanup manually with values higher than 0. What about splitting these two functions : first part is signal(int signum) second part is cleanup(int ret)
This function was used in two different ways :
- as a signal handler : the argument was the signal number
- called manually for freeing the resources : the argument was the return
value
So the first part is now handler(int), and the second cleanup(int).
Ref: http://www.archlinux.org/pipermail/pacman-dev/2008-March/011388.html
Remaining problems :
- the return values are messy. for example, 2 can mean both that it was
interrupted (SIGINT == 2), or that --help or -V was used (returned by
parseargs).
- apparently signal is not portable and sigaction should be used instead
Signed-off-by: Chantry Xavier
On Sun, Mar 9, 2008 at 7:05 AM, Chantry Xavier
This function was used in two different ways : - as a signal handler : the argument was the signal number - called manually for freeing the resources : the argument was the return value So the first part is now handler(int), and the second cleanup(int). Ref: http://www.archlinux.org/pipermail/pacman-dev/2008-March/011388.html
Remaining problems : - the return values are messy. for example, 2 can mean both that it was interrupted (SIGINT == 2), or that --help or -V was used (returned by parseargs). - apparently signal is not portable and sigaction should be used instead
Signed-off-by: Chantry Xavier
---
Applied, thanks.
On Sun, Mar 9, 2008 at 6:20 AM, Xavier
On Sun, Mar 09, 2008 at 11:40:48AM +0100, Nagy Gabor wrote:
Cleanup() is a signal handler. However, we usually pass some return values to it manually, see lines 816 and 822 for example. Or run pacman -V --debug. (parseargs returns with 2 == SIGINT) Is this OK?
Huh yes, all these cleanup calls don't look right.. Well, we only listen to SIGINT 2, SIGTERM 15 and SIGSEGV 11, but still we shouldn't call cleanup manually with values higher than 0.
What about splitting these two functions : first part is signal(int signum) second part is cleanup(int ret)
+1 -Dan
participants (4)
-
Chantry Xavier
-
Dan McGee
-
Nagy Gabor
-
Xavier