             args.push '-p'
             args.push settings.port
         if detached
-            args.push '>'
-            args.push settings.stdout or '/dev/null'
-        if detached
-            args.push '2>'
-            args.push settings.stderr or '/dev/null'
-        args.unshift 'cloud9'
-        args = args.join ' '
-        cloud9 = exec args
+            args.push '</dev/null'
+            args.push '>' + settings.stdout
+            args.push '2>' + settings.stderr
+        cloud9 = spawn 'cloud9', args #, {setsid: true}
         if detached
             pidfile = settings.pidfile or '/tmp/cloud9.pid'
             fs.writeFileSync pidfile, '' + cloud9.pid

                res.prompt()
            cloud9.kill()
        else
            console.log 'this should not appear'
            res.prompt()


    shell.on 'exit', ->
        cloud9.kill() if shell.isShell and not settings.detach and cloud9
    shell.cmd 'cloud9 start', 'Start Cloud9', (req, res, next) ->
        args = []
        detached = not shell.isShell or settings.detach
        args.push '-w'
        args.push settings.workspace
