From: michi1@michaelblizek.twilightparadox.com (michi1 at michaelblizek.twilightparadox.com)
To: kernelnewbies@lists.kernelnewbies.org
Subject: signals handling: kill() successful, but nothing delivered
Date: Fri, 8 Mar 2013 06:52:46 +0100 [thread overview]
Message-ID: <20130308055245.GA2221@grml> (raw)
Hi!
I am trying to test for signal handling race conditions (specifically, I
suspect the kernel side of connect() does interesting things if the server
response arrives while the program executes a signal handler) and want to
flood a program with lots of signals. So I have run this:
---
#!/bin/bash
while [ 1 -eq 1 ]; do
killall -s SIGURG wget 2> /dev/null
done
---
...and then then executed:
strace wget -O - "http://kernel.org"
...
connect(3, {sa_family=AF_INET, sin_port=htons(80), sin_addr=inet_addr("198.145.20.140")}, 16) = ? ERESTARTSYS (To be restarted)
--- SIGURG (Urgent I/O condition) @ 0 (0) ---
connect(3, {sa_family=AF_INET, sin_port=htons(80), sin_addr=inet_addr("198.145.20.140")}, 16) = ? ERESTARTSYS (To be restarted)
--- SIGURG (Urgent I/O condition) @ 0 (0) ---
connect(3, {sa_family=AF_INET, sin_port=htons(80), sin_addr=inet_addr("198.145.20.140")}, 16) = 0
...
It shows that signals arrive, but no interesting behaviour yet. I suspect this
is because the rate signals are sent is too low. So I come up with this:
---
#include <sys/types.h>
#include <signal.h>
#include <stdio.h>
int main(int argc, char **argv)
{
int pid;
int rc = 0;
if (argc < 2)
return 1;
pid = atoi(argv[1]);
if (pid <= 1 || pid >= 65536)
return 1;
printf("kill %d %d\n", pid, SIGURG);
while (kill(pid, SIGURG) == 0) {
printf("signal sent\n"); /* probably slow, remove later */
}
perror("killloop end");
return 0;
}
---
#!/bin/bash
while [ 1 -eq 1 ]; do
./a.out `ps a|grep wget|grep -v grep|sed "s/^[^0-9]*\([0-9]*\).*$/\1/"`
done
---
The output looks like this:
kill 15574 23
signal sent
signal sent
signal sent
...
signal sent
signal sent
signal sent
killloop end: No such process
However, no signal arrives. But if I change SIGURG to SIGTERM, they arrive!
Why does SIGURG arrive when sent with "killall -s SIGURG wget", but not when
sent with my test prog?
-Michi
--
programing a layer 3+4 network protocol for mesh networks
see http://michaelblizek.twilightparadox.com
next reply other threads:[~2013-03-08 5:52 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-03-08 5:52 michi1 at michaelblizek.twilightparadox.com [this message]
2013-03-18 5:50 ` signals handling: kill() successful, but nothing delivered michi1 at michaelblizek.twilightparadox.com
2013-03-18 15:59 ` Valdis.Kletnieks at vt.edu
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20130308055245.GA2221@grml \
--to=michi1@michaelblizek.twilightparadox.com \
--cc=kernelnewbies@lists.kernelnewbies.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).