748554 - dont mess up python exit codes

Authored and Committed by Panu Matilainen 17 years ago
    - dont mess up python exit codes
    
        
rpm-4.4.2.1-checkterminate-noexit.patch ADDED
@@ -0,0 +1,105 @@
1
+ changeset: 6179:fb37e4dccbf3
2
+ tag: tip
3
+ user: Panu Matilainen <pmatilai@redhat.com>
4
+ date: Sat Jul 21 15:05:19 2007 +0300
5
+ files: python/rpmmodule.c rpmdb/rpmdb.c rpmdb/rpmdb.h
6
+ description:
7
+ Make rpmdbCheckTerminate() non-terminating.
8
+ This allows use in exit handler without affecting exit code, and permits
9
+ caller to do its own cleanup if necessary.
10
+
11
+
12
+ diff -r e9ced408b17f -r fb37e4dccbf3 python/rpmmodule.c
13
+ --- a/python/rpmmodule.c Fri Jul 20 11:23:11 2007 +0300
14
+ +++ b/python/rpmmodule.c Sat Jul 21 15:05:19 2007 +0300
15
+ @@ -229,8 +229,6 @@ static PyMethodDef rpmModuleMethods[] =
16
+
17
+ /*
18
+ * Force clean up of open iterators and dbs on exit.
19
+ -* This ends up calling exit() while we're already exiting but exit
20
+ -* handlers will only get called once so it wont loop.
21
+ */
22
+ static void rpm_exithook(void)
23
+ {
24
+ diff -r e9ced408b17f -r fb37e4dccbf3 rpmdb/rpmdb.c
25
+ --- a/rpmdb/rpmdb.c Fri Jul 20 11:23:11 2007 +0300
26
+ +++ b/rpmdb/rpmdb.c Sat Jul 21 15:05:19 2007 +0300
27
+ @@ -707,7 +707,7 @@ int rpmdbCheckTerminate(int terminate)
28
+ sigset_t newMask, oldMask;
29
+ static int terminating = 0;
30
+
31
+ - if (terminating) return 0;
32
+ + if (terminating) return 1;
33
+
34
+ (void) sigfillset(&newMask); /* block all signals */
35
+ (void) sigprocmask(SIG_BLOCK, &newMask, &oldMask);
36
+ @@ -724,10 +724,6 @@ int rpmdbCheckTerminate(int terminate)
37
+ rpmdb db;
38
+ rpmdbMatchIterator mi;
39
+
40
+ -/*@-abstract@*/ /* sigset_t is abstract type */
41
+ - rpmMessage(RPMMESS_DEBUG, "Exiting on signal(0x%lx) ...\n", *((unsigned long *)&rpmsqCaught));
42
+ -/*@=abstract@*/
43
+ -
44
+ /*@-branchstate@*/
45
+ while ((mi = rpmmiRock) != NULL) {
46
+ /*@i@*/ rpmmiRock = mi->mi_next;
47
+ @@ -743,14 +739,20 @@ int rpmdbCheckTerminate(int terminate)
48
+ (void) rpmdbClose(db);
49
+ }
50
+ /*@=newreftrans@*/
51
+ + }
52
+ + sigprocmask(SIG_SETMASK, &oldMask, NULL);
53
+ + return terminating;
54
+ +}
55
+ +
56
+ +int rpmdbCheckSignals(void)
57
+ +{
58
+ + if (rpmdbCheckTerminate(0)) {
59
+ +/*@-abstract@*/ /* sigset_t is abstract type */
60
+ + rpmMessage(RPMMESS_DEBUG, "Exiting on signal(0x%lx) ...\n", *((unsigned long *)&rpmsqCaught));
61
+ exit(EXIT_FAILURE);
62
+ - }
63
+ - return sigprocmask(SIG_SETMASK, &oldMask, NULL);
64
+ -}
65
+ -
66
+ -int rpmdbCheckSignals(void)
67
+ -{
68
+ - return rpmdbCheckTerminate(0);
69
+ +/*@=abstract@*/
70
+ + }
71
+ + return 0;
72
+ }
73
+
74
+ /**
75
+ diff -r e9ced408b17f -r fb37e4dccbf3 rpmdb/rpmdb.h
76
+ --- a/rpmdb/rpmdb.h Fri Jul 20 11:23:11 2007 +0300
77
+ +++ b/rpmdb/rpmdb.h Sat Jul 21 15:05:19 2007 +0300
78
+ @@ -1039,8 +1039,7 @@ Header rpmdbNextIterator(/*@null@*/ rpmd
79
+ /*@modifies mi, rpmGlobalMacroContext, fileSystem, internalState @*/;
80
+
81
+ /** \ingroup rpmdb
82
+ - * Check rpmdb signal handler for trapped signal exit. Just a compatibility
83
+ - * wrapper for rpmdbCheckTerminate()
84
+ + * Check for and exit on termination signals.
85
+ */
86
+ /*@mayexit@*/
87
+ int rpmdbCheckSignals(void)
88
+ @@ -1048,10 +1047,13 @@ int rpmdbCheckSignals(void)
89
+ /*@modifies fileSystem, internalState @*/;
90
+
91
+ /** \ingroup rpmdb
92
+ - * Check rpmdb signal handler for trapped signal or requested exit.
93
+ + * Check rpmdb signal handler for trapped signal and/or requested exit,
94
+ + * clean up any open iterators and databases on termination condition.
95
+ + * On non-zero exit any open references to rpmdb are invalid and cannot
96
+ + * be accessed anymore, calling process should terminate immediately.
97
+ * @param terminate 0 to only check for signals, 1 to terminate anyway
98
+ - */
99
+ -/*@mayexit@*/
100
+ + * @return 0 to continue, 1 if termination cleanup was done.
101
+ + */
102
+ int rpmdbCheckTerminate(int terminate);
103
+
104
+ /** \ingroup rpmdb
105
+
file modified
+6 -1
rpm.spec CHANGED
@@ -14,7 +14,7 @@ Summary: The RPM package management system
14
14
Name: rpm
15
15
Version: 4.4.2.1
16
16
%{expand: %%define rpm_version %{version}-rc3}
17
- Release: 0.5.rc3
17
+ Release: 0.6.rc3
18
18
Group: System Environment/Base
19
19
Url: http://www.rpm.org/
20
20
Source: rpm-%{rpm_version}.tar.gz
@@ -27,6 +27,7 @@ Patch6: rpm-4.4.2-matchpathcon.patch
27
27
Patch7: rpm-4.4.2.1-checksignals.patch
28
28
Patch8: rpm-4.4.2.1-checkterminate.patch
29
29
Patch9: rpm-4.4.2.1-python-exithook.patch
30
+ Patch10: rpm-4.4.2.1-checkterminate-noexit.patch
30
31
License: GPL
31
32
Requires(pre): shadow-utils
32
33
Requires(postun): shadow-utils
@@ -140,6 +141,7 @@ shell-like rules.
140
141
%patch7 -p1 -b .checksignals
141
142
%patch8 -p1 -b .checkterminate
142
143
%patch9 -p1 -b .py-exithook
144
+ %patch10 -p1 -b .checkterminate-noexit
143
145
144
146
%build
145
147
@@ -436,6 +438,9 @@ exit 0
436
438
%{__includedir}/popt.h
437
439
438
440
%changelog
441
+ * Sat Jul 21 2007 Panu Matilainen <pmatilai@redhat.com> 4.4.2.1-0.6.rc3
442
+ - dont mess up python exit codes
443
+
439
444
* Fri Jul 20 2007 Panu Matilainen <pmatilai@redhat.com> 4.4.2.1-0.5.rc3
440
445
- require logrotate (#248629)
441
446
- allow checking for pending signals from python (#181434)