diff options
| author | Jan Kiszka <jan.kiszka@siemens.com> | 2010-10-15 07:50:51 -0400 |
|---|---|---|
| committer | Steven Rostedt <rostedt@goodmis.org> | 2010-10-15 12:33:00 -0400 |
| commit | 84cc30df9c35a3ccb79e34bc931c3edb979b2412 (patch) | |
| tree | 8a3034533476dc9789961b153cc3fb5c7a36bf3d | |
| parent | fe754048865035a461d361da851e0509e0c1419f (diff) | |
trace-cmd: Plug startup race between flush_threads and recorders
As the SIGUSR1 handler is so far registered after forking the recorder
child, there is a small race window where a flush sent by the main
process can actually kill the child. Plug this by registering the signal
handlers before the fork. This also allows to unify SIGINT registration.
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
LKML-Reference: <4CB8401B.2020801@siemens.com>
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
| -rw-r--r-- | trace-cmd.c | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/trace-cmd.c b/trace-cmd.c index 9cbe362..f8992a8 100644 --- a/trace-cmd.c +++ b/trace-cmd.c | |||
| @@ -1089,6 +1089,8 @@ static int create_recorder(int cpu) | |||
| 1089 | char *file; | 1089 | char *file; |
| 1090 | int pid; | 1090 | int pid; |
| 1091 | 1091 | ||
| 1092 | signal(SIGUSR1, flush); | ||
| 1093 | |||
| 1092 | pid = fork(); | 1094 | pid = fork(); |
| 1093 | if (pid < 0) | 1095 | if (pid < 0) |
| 1094 | die("fork"); | 1096 | die("fork"); |
| @@ -1096,9 +1098,6 @@ static int create_recorder(int cpu) | |||
| 1096 | if (pid) | 1098 | if (pid) |
| 1097 | return pid; | 1099 | return pid; |
| 1098 | 1100 | ||
| 1099 | signal(SIGINT, finish); | ||
| 1100 | signal(SIGUSR1, flush); | ||
| 1101 | |||
| 1102 | if (rt_prio) | 1101 | if (rt_prio) |
| 1103 | set_prio(rt_prio); | 1102 | set_prio(rt_prio); |
| 1104 | 1103 | ||
| @@ -1694,9 +1693,9 @@ int main (int argc, char **argv) | |||
| 1694 | set_options(); | 1693 | set_options(); |
| 1695 | 1694 | ||
| 1696 | if (record || extract) { | 1695 | if (record || extract) { |
| 1696 | signal(SIGINT, finish); | ||
| 1697 | if (!latency) | 1697 | if (!latency) |
| 1698 | start_threads(); | 1698 | start_threads(); |
| 1699 | signal(SIGINT, finish); | ||
| 1700 | } | 1699 | } |
| 1701 | 1700 | ||
| 1702 | if (extract) { | 1701 | if (extract) { |
