crash-manager: Provide TID as optional value of an -i option 76/257776/2
authorMateusz Moscicki <m.moscicki2@partner.samsung.com>
Fri, 30 Apr 2021 10:21:48 +0000 (12:21 +0200)
committerMateusz Moscicki <m.moscicki2@partner.samsung.com>
Fri, 30 Apr 2021 12:52:36 +0000 (14:52 +0200)
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

src/crash-manager/70-crash-manager.conf.in
src/crash-manager/main.c

index f788a2e..09c7395 100644 (file)
@@ -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
index def780c..961bb18 100644 (file)
@@ -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);