From 31be80f02cddda55e75614884038fa4645b694cd Mon Sep 17 00:00:00 2001 From: Glenn Kasten Date: Tue, 5 Jun 2012 16:42:22 -0700 Subject: [PATCH] Add -n and -S options for 'nohup', offline traces Change-Id: Ieef12b36b8519ff689ab5a81447b1b9bf4806171 --- cmds/atrace/atrace.c | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/cmds/atrace/atrace.c b/cmds/atrace/atrace.c index 5edc47b38..890165af8 100644 --- a/cmds/atrace/atrace.c +++ b/cmds/atrace/atrace.c @@ -39,6 +39,8 @@ static bool g_traceWorkqueue = false; static bool g_traceOverwrite = false; static int g_traceBufferSizeKB = 2048; static bool g_compress = false; +static bool g_nohup = false; +static int g_initialSleepSecs = 0; /* Global state */ static bool g_traceAborted = false; @@ -417,7 +419,9 @@ static void showHelp(const char *cmd) } static void handleSignal(int signo) { - g_traceAborted = true; + if (!g_nohup) { + g_traceAborted = true; + } } static void registerSigHandler() { @@ -443,7 +447,7 @@ int main(int argc, char **argv) for (;;) { int ret; - ret = getopt(argc, argv, "b:cidflst:uwz"); + ret = getopt(argc, argv, "b:cidflst:uwznS:"); if (ret < 0) { break; @@ -478,10 +482,18 @@ int main(int argc, char **argv) g_traceFrequency = true; break; + case 'n': + g_nohup = true; + break; + case 's': g_traceSchedSwitch = true; break; + case 'S': + g_initialSleepSecs = atoi(optarg); + break; + case 't': g_traceDurationSeconds = atoi(optarg); break; @@ -516,6 +528,10 @@ int main(int argc, char **argv) registerSigHandler(); + if (g_initialSleepSecs > 0) { + sleep(g_initialSleepSecs); + } + bool ok = startTrace(isRoot); if (ok) {