--=_courier-29312-1057608964-0001-2
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
This are updated versions of the patch Ingo sent some time ago to
implement a new tgkill() syscall which can in theory replace kill() and
tkill().
The first patch is just Ingo's patch, relative to the current BK
sources, plus the fix to send the correct si_pid value.
The second patch implementation the additional functionality Linus
proposed. They allow using tgkill as a replacement for kill/tkill by
recognizing special -1 values. This is the interdiff:
- --- linux-2.5/kernel/signal.c 2003-07-07 12:39:36.000000000 -0700
+++ linux-2.5/kernel/signal.c 2003-07-07 13:03:15.000000000 -0700
@@ -2104,8 +2104,12 @@
int error;
struct task_struct *p;
+ /* Handle tgkill(tgid, -1, sig) like kill(tgid, sig). */
+ if (pid == -1)
+ return sys_kill(tgid, sig);
+
/* This is only valid for single tasks */
- - if (pid <= 0 || tgid <= 0)
+ if (pid <= 0 || tgid < -1 || tgid == 0)
return -EINVAL;
info.si_signo = sig;
@@ -2117,7 +2121,8 @@
read_lock(&tasklist_lock);
p = find_task_by_pid(pid);
error = -ESRCH;
- - if (p && (p->tgid == tgid)) {
+ /* Handle tgkill(-1, pid, sig) like tkill(pid, sig). */
+ if (p && (p->tgid == tgid || tgid == -1)) {
error = check_kill_permission(sig, &info, p);
/*
* The null signal is a permissions and process existence
I personally would think that this addition is overkill since we cannot
get rid of the kill/tkill syscalls anyway.
I've tested both patches. Having one of them included is really needed
since many/most people still run with limited PID ranges (maybe due to
legacy apps breaking) and the PID reuse can cause problems.
Let me know if there are any problems. I'll try to address them right away.
- --
- --------------. ,-. 444 Castro Street
Ulrich Drepper \ ,-----------------' \ Mountain View, CA 94041 USA
Red Hat `--' drepper at redhat.com `---------------------------
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.1 (GNU/Linux)
iD8DBQE/CdSE2ijCOnn/RHQRAiytAJwJq8BYPRu9Ep6U8krubKafW7nVwwCeKsq7
LKsQB68ROJYi8OrdUPFOZ5M=
=HdOW
-----END PGP SIGNATURE-----
--=_courier-29312-1057608964-0001-2
Content-Type: text/plain; name=d-kernel-tgkill1; charset=iso-8859-1
Content-Transfer-Encoding: base64
Content-Disposition: inline;
filename="d-kernel-tgkill1"
LS0tIGxpbnV4LTIuNS9hcmNoL2kzODYva2VybmVsL2VudHJ5LlMtb2xkCTIwMDMtMDYtMjQg
MDk6NDA6MTIuMDAwMDAwMDAwIC0wNzAwCisrKyBsaW51eC0yLjUvYXJjaC9pMzg2L2tlcm5l
bC9lbnRyeS5TCTIwMDMtMDctMDcgMTI6MzY6NTUuMDAwMDAwMDAwIC0wNzAwCkBAIC04NzYs
NSArODc2LDYgQEAgRU5UUlkoc3lzX2NhbGxfdGFibGUpCiAgCS5sb25nIHN5c19jbG9ja19u
YW5vc2xlZXAKIAkubG9uZyBzeXNfc3RhdGZzNjQKIAkubG9uZyBzeXNfZnN0YXRmczY0CQor
CS5sb25nIHN5c190Z2tpbGwKICAKIG5yX3N5c2NhbGxzPSguLXN5c19jYWxsX3RhYmxlKS80
Ci0tLSBsaW51eC0yLjUvaW5jbHVkZS9hc20taTM4Ni91bmlzdGQuaC1vbGQJMjAwMy0wNi0y
NCAwOTo0MDoxMy4wMDAwMDAwMDAgLTA3MDAKKysrIGxpbnV4LTIuNS9pbmNsdWRlL2FzbS1p
Mzg2L3VuaXN0ZC5oCTIwMDMtMDctMDcgMTI6MzI6MzcuMDAwMDAwMDAwIC0wNzAwCkBAIC0y
NzUsOCArMjc1LDkgQEAKICNkZWZpbmUgX19OUl9jbG9ja19uYW5vc2xlZXAJKF9fTlJfdGlt
ZXJfY3JlYXRlKzgpCiAjZGVmaW5lIF9fTlJfc3RhdGZzNjQJCTI2OAogI2RlZmluZSBfX05S
X2ZzdGF0ZnM2NAkJMjY5CisjZGVmaW5lIF9fTlJfdGdraWxsCQkyNzAKIAotI2RlZmluZSBO
Ul9zeXNjYWxscyAyNzAKKyNkZWZpbmUgTlJfc3lzY2FsbHMgMjcxCiAKIC8qIHVzZX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mFsIGlzIGEgcGVybWlzc2lv
bnMgYW5kIHByb2Nlc3MgZXhpc3RlbmNlCisJCSAqIHByb2JlLiAgTm8gc2lnbmFsIGlzIGFj
dHVhbGx5IGRlbGl2ZXJlZC4KKwkJICovCisJCWlmICghZXJyb3IgJiYgc2lnICYmIHAtPnNp
Z2hhbmQpIHsKKwkJCXNwaW5fbG9ja19pcnEoJnAtPnNpZ2hhbmQtPnNpZ2xvY2spOworCQkJ
aGFuZGxlX3N0b3Bfc2lnbmFsKHNpZywgcCk7CisJCQllcnJvciA9IHNwZWNpZmljX3NlbmRf
c2lnX2luZm8oc2lnLCAmaW5mbywgcCk7CisJCQlzcGluX3VubG9ja19pcnEoJnAtPnNpZ2hh
bmQtPnNpZ2xvY2spOworCQl9CisJfQorCXJlYWRfdW5sb2NrKCZ0YXNrbGlzdF9sb2NrKTsK
KwlyZXR1cm4gZXJyb3I7Cit9CisKIC8qCiAgKiAgU2VuZCBhIHNpZ25hbCB0byBvbmx5IG9u
ZSB0YXNrLCBldmVuIGlmIGl0J3MgYSBDTE9ORV9USFJFQUQgdGFzay4KICAqLwo=
--=_courier-29312-1057608964-0001-2
Content-Type: text/plain; name=d-kernel-tgkill2; charset=iso-8859-1
Content-Transfer-Encoding: base64
Content-Disposition: inline;
filename="d-kernel-tgkill2"
LS0tIGxpbnV4LTIuNS9hcmNoL2kzODYva2VybmVsL2VudHJ5LlMtb2xkCTIwMDMtMDYtMjQg
MDk6NDA6MTIuMDAwMDAwMDAwIC0wNzAwCisrKyBsaW51eC0yLjUvYXJjaC9pMzg2L2tlcm5l
bC9lbnRyeS5TCTIwMDMtMDctMDcgMTI6MzY6NTUuMDAwMDAwMDAwIC0wNzAwCkBAIC04NzYs
NSArODc2LDYgQEAgRU5UUlkoc3lzX2NhbGxfdGFibGUpCiAgCS5sb25nIHN5c19jbG9ja19u
YW5vc2xlZXAKIAkubG9uZyBzeXNfc3RhdGZzNjQKIAkubG9uZyBzeXNfZnN0YXRmczY0CQor
CS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