summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMateusz Moscicki <m.moscicki2@partner.samsung.com>2018-08-31 15:40:54 +0200
committerMateusz Moscicki <m.moscicki2@partner.samsung.com>2018-09-05 09:32:14 +0200
commita6914660f26680f78af993c99bc3bd5736ea5c3e (patch)
tree2337fe76fa5a78560c64d340ee3d1fdeac1a337b
parent441ff63bdb63c421183c929bd783ba1084ff719d (diff)
downloadcrash-worker-a6914660f26680f78af993c99bc3bd5736ea5c3e.tar.gz
crash-worker-a6914660f26680f78af993c99bc3bd5736ea5c3e.tar.bz2
crash-worker-a6914660f26680f78af993c99bc3bd5736ea5c3e.zip
Add timeout to the zip command
Change-Id: I52db6f8ccd1a2103da030c10898ec33c4a9bcc57
-rw-r--r--src/crash-manager/crash-manager.c31
1 files changed, 25 insertions, 6 deletions
diff --git a/src/crash-manager/crash-manager.c b/src/crash-manager/crash-manager.c
index 4c760bf..8add845 100644
--- a/src/crash-manager/crash-manager.c
+++ b/src/crash-manager/crash-manager.c
@@ -75,6 +75,7 @@
#define MINICOREDUMPER_TIMEOUT 12*60
#define CRASH_STACK_TIMEOUT 12*60
+#define ZIP_TIMEOUT 12*60
#define TEMP_MAPS_FILENAME "maps.temp"
enum {
@@ -1130,7 +1131,7 @@ static void compress(struct crash_info *cinfo)
{
int ret, lock_fd;
char zip_path[PATH_MAX];
- char command[PATH_MAX];
+ char cwd[PATH_MAX];
ret = snprintf(zip_path, sizeof(zip_path), "%s/report.zip",
cinfo->temp_dir);
@@ -1139,13 +1140,31 @@ static void compress(struct crash_info *cinfo)
return;
}
- ret = snprintf(command, sizeof(command), "cd %s && /bin/zip -y -r %s %s > /dev/null 2>&1",
- cinfo->temp_dir, zip_path, cinfo->name);
- if (ret < 0) {
- _E("Failed to snprintf for zip command");
+ if (getcwd(cwd, sizeof(cwd)) == NULL) {
+ _E("getcwd() error: %m\n");
+ return;
+ }
+
+ if (chdir(cinfo->temp_dir) == -1) {
+ _E("chdir() to %s error: %m\n", cinfo->temp_dir);
+ return;
+ }
+
+ char *args[] = {
+ "/bin/zip",
+ "-y",
+ "-r",
+ zip_path,
+ cinfo->name,
+ NULL
+ };
+
+ run_command_timeout(args[0], args, NULL, ZIP_TIMEOUT);
+
+ if (chdir(cwd) == -1) {
+ _E("chdir() to %s error: %m\n", cwd);
return;
}
- system_command(command);
if ((lock_fd = lock_dumpdir()) < 0)
return;