aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSteven Rostedt <srostedt@redhat.com>2010-02-03 15:41:08 -0500
committerSteven Rostedt <rostedt@goodmis.org>2010-02-03 15:41:08 -0500
commitaa89e253617492653a090dbf48d36df6def84f9a (patch)
tree0d48b45092d1e091ab2dc5beb17c115208dc9cdb
parenta0e84ac41863a6f98ea31fa7d7701b24c5288c4b (diff)
trace-cmd: Handle zeroing of set_ftrace_pid on older kernels
Older kernels require a "-1" be passed into set_ftrace_pid to zero it out. Newer kernels need just an empty string. The sad part is that using the wrong one will cause the write to fail. Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
-rw-r--r--trace-cmd.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/trace-cmd.c b/trace-cmd.c
index 1365a73..be1241c 100644
--- a/trace-cmd.c
+++ b/trace-cmd.c
@@ -267,6 +267,7 @@ static void reset_max_latency(void)
267static void update_ftrace_pid(const char *pid) 267static void update_ftrace_pid(const char *pid)
268{ 268{
269 char *path; 269 char *path;
270 int ret;
270 int fd; 271 int fd;
271 272
272 path = get_tracing_file("set_ftrace_pid"); 273 path = get_tracing_file("set_ftrace_pid");
@@ -277,7 +278,15 @@ static void update_ftrace_pid(const char *pid)
277 if (fd < 0) 278 if (fd < 0)
278 return; 279 return;
279 280
280 if (write(fd, pid, strlen(pid)) < 0) 281 ret = write(fd, pid, strlen(pid));
282
283 /*
284 * Older kernels required "-1" to disable pid
285 */
286 if (ret < 0 && !strlen(pid))
287 ret = write(fd, "-1", 2);
288
289 if (ret < 0)
281 die("error writing to %s", path); 290 die("error writing to %s", path);
282 291
283 close(fd); 292 close(fd);