title: Use of posix_spawn?
body: <p>I try to start a command file from my app, so I need to use "posix_spawn". But usage of this requires strange use of pointers. I didn't find any example of Swift (3.0), only C++ or Objective C which I couldn't translate.</p>
  
  <p>I simply need something like that (in old system call):</p>
  
  <pre><code>let err = system("ls -param &gt;file.txt")
  </code></pre>
  
  <p>Any ideas?</p>
  
  <p>Edit:
  The linked solution didn't match.
  First it does not use posix_spawn function, which was mentioned by the complier. It uses NSTask, which seems also be abandoned. But I tried this example and ended up in:</p>
  
  <pre><code>func shell(launchPath: String, arguments: [String]) -&gt; String
  {
      let task = Process()
      task.launchPath = launchPath
      task.arguments = arguments
  
      let pipe = Pipe()
      task.standardOutput = pipe
      task.launch()
  
      let data = pipe.fileHandleForReading.readDataToEndOfFile()
      let output: String = NSString(data: data, encoding: String.Encoding.utf8.rawValue)! as String
  
      return output
  }
  </code></pre>
  
  <p>Here all changes needed for XCode 8 were made. But when calling, it will never return from ".launch()".</p>
  
  <p>Somewhere in Output debug window I found this line:</p>
  
  <pre><code>2016-09-15 15:06:36.793 DSRenamer[96562:2569582] launch path not accessible
  </code></pre>
  
  <p>Same command works fine in terminal window:</p>
  
  <pre><code>/usr/local/bin/ExifTool -ext .CR2
  </code></pre>