From: Mateusz Moscicki Date: Fri, 30 Apr 2021 10:21:48 +0000 (+0200) Subject: crash-manager: Provide TID as optional value of an -i option X-Git-Tag: accepted/tizen/unified/20210505.141406~1 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=17196db27652a8540fb0f6103de5841653f9fb32;p=platform%2Fcore%2Fsystem%2Fcrash-worker.git crash-manager: Provide TID as optional value of an -i option Since %i can only be specified in core_pattern since kernel 3.18, crash-manager must handle the situation where no value is specified for this parameter. This is implemented in this commit, but the value for the -i parameter must be specified without spaces. Change-Id: I2cc2ff5d527a638c0f52df180c3875daf6208e02 --- diff --git a/src/crash-manager/70-crash-manager.conf.in b/src/crash-manager/70-crash-manager.conf.in index f788a2e..09c7395 100644 --- a/src/crash-manager/70-crash-manager.conf.in +++ b/src/crash-manager/70-crash-manager.conf.in @@ -1,5 +1,5 @@ # Tizen crash-manager -kernel.core_pattern=|/usr/bin/crash-manager -E %E -p %p -u %u -g %g -s %s -t %t +kernel.core_pattern=|/usr/bin/crash-manager -E %E -p %p -u %u -g %g -s %s -t %t -i%i kernel.core_pipe_limit=10 # All processes should be dumped fs.suid_dumpable=2 diff --git a/src/crash-manager/main.c b/src/crash-manager/main.c index def780c..961bb18 100644 --- a/src/crash-manager/main.c +++ b/src/crash-manager/main.c @@ -24,6 +24,7 @@ static void print_help(const char *name) " -u --uid=UID real UID of dumped process\n" " -g --gid=GID real GID of dumped process\n" " -i --tid=TID TID of thread that triggered core dump\n" + " (with short option TID must be specified without spaces)\n" " -s --signal=SIG number of signal causing dump\n" " -t --time=TIME time of dump, expressed as seconds since the Epoch\n" " -l --live get coredump of running process\n" @@ -62,7 +63,7 @@ static bool parse_args(struct crash_info *cinfo, int argc, char *argv[]) {"pid", required_argument, NULL, 'p'}, {"uid", required_argument, NULL, 'u'}, {"gid", required_argument, NULL, 'g'}, - {"tid", required_argument, NULL, 'i'}, + {"tid", optional_argument, NULL, 'i'}, {"signal", required_argument, NULL, 's'}, {"time", required_argument, NULL, 't'}, {"live", no_argument, NULL, 'l'}, @@ -73,7 +74,7 @@ static bool parse_args(struct crash_info *cinfo, int argc, char *argv[]) {"executable-path", required_argument, NULL, 'E'}, }; - while ((opt = getopt_long(argc, argv, "p:u:g:i:s:t:hlkro:E:", long_options, NULL)) != -1) { + while ((opt = getopt_long(argc, argv, "p:u:g:i::s:t:hlkro:E:", long_options, NULL)) != -1) { switch (opt) { case 'p': GET_NUMBER(pid); @@ -88,7 +89,8 @@ static bool parse_args(struct crash_info *cinfo, int argc, char *argv[]) gid_set = true; break; case 'i': - GET_NUMBER(tid); + if (optarg != NULL) + GET_NUMBER(tid); break; case 's': GET_NUMBER(sig);