diff --git a/services/filestore/app/coffee/FileConverter.coffee b/services/filestore/app/coffee/FileConverter.coffee index d791e4c2d0..bf38833017 100644 --- a/services/filestore/app/coffee/FileConverter.coffee +++ b/services/filestore/app/coffee/FileConverter.coffee @@ -1,7 +1,7 @@ _ = require("underscore") metrics = require("metrics-sharelatex") logger = require("logger-sharelatex") -safe_exec = require('./SafeExec') +safe_exec = require("./SafeExec") approvedFormats = ["png"] fourtySeconds = 40 * 1000 diff --git a/services/filestore/app/coffee/SafeExec.coffee b/services/filestore/app/coffee/SafeExec.coffee index 0244f14783..217aab4748 100644 --- a/services/filestore/app/coffee/SafeExec.coffee +++ b/services/filestore/app/coffee/SafeExec.coffee @@ -9,6 +9,7 @@ child_process = require('child_process') # group, then we can kill everything in that process group. module.exports = (command, options, callback = (err, stdout, stderr) ->) -> + # options are {timeout: number-of-milliseconds, killSignal: signal-name} [cmd, args...] = command.split(' ') child = child_process.spawn cmd, args, {detached:true} @@ -22,6 +23,7 @@ module.exports = (command, options, callback = (err, stdout, stderr) ->) -> if options.timeout? killTimer = setTimeout () -> try + # use negative process id to kill process group process.kill -child.pid, options.killSignal || "SIGTERM" catch error logger.log process: child.pid, kill_error: error, "error killing process"