   version: null
   socketPath: '/tmp/atom.sock'
 
-  constructor: ({@resourcePath, @executedFrom, @pathsToOpen, @testMode, @version}) ->
+  constructor: ({@resourcePath, @executedFrom, @pathsToOpen, @testMode, @version, wait, pid}) ->
+    @pidsToOpenWindows = {}
     if @pathsToOpen?
       @pathsToOpen = @pathsToOpen.map (pathToOpen) =>
         path.resolve(@executedFrom, pathToOpen)
+    else if @executedFrom
+      @pathsToOpen = [@executedFrom]
     else
-      @pathsToOpen = [@executedFrom] if @executedFrom
+      @pathsToOpen = [null]
 
     @executedFrom ?= process.cwd()
+    pidToKillWhenClosed = pid if wait
     atomApplication = this
     @windows = []
 
-    @sendArgumentsToExistingProcess (success) =>
+    @sendArgumentsToExistingProcess pidToKillWhenClosed, (success) =>
       process.exit(0) if success # An Atom already exists, kill this process
       @listenForArgumentsFromNewProcess()
       @setupNodePath()

      if @testMode
        @runSpecs(true)
      else
        @open(@pathsToOpen)

  removeWindow: (window) ->
    @windows.splice @windows.indexOf(window), 1

    fs.unlinkSync @socketPath if fs.existsSync(@socketPath)
    server = net.createServer (connection) =>
      connection.on 'data', (data) =>
        {pathsToOpen, pidToKillWhenClosed} = JSON.parse(data)
        @openPaths(pathsToOpen, pidToKillWhenClosed)

    server.listen @socketPath
    server.on 'error', (error) -> console.error 'Application server failed', error
