title: Error when using killall with NSTask (operation not permitted)
body: <p>I am trying to kill Finder so it restarts after I make a change using NSTask(). Below is what I am trying to do at the moment in Swift, the problem is I am getting an error and I can't work out how to fix it.</p>
  
  <p>Code: </p>
  
  <pre><code>var task = NSTask()
  task.launchPath = "/usr/bin/defaults"
  task.arguments = ["write", "com.apple.finder", "AppleShowAllFiles", "YES"]
  task.launch()
  task.waitUntilExit()
  
  var taskKill = NSTask()
  taskKill.launchPath = "/usr/bin/killall"
  taskKill.arguments = ["Finder"]
  taskKill.launch()
  </code></pre>
  
  <p>And the error I am getting:</p>
  
  <pre><code>killall: warning: kill -TERM 5185: Operation not permitted
  </code></pre>
  
  <p>I have searched all over the internet for a solution to this. Some suggested turning on Sandbox which I did and nothing changed, and some said that I need to get permission from the user which is a poorly documented part of OS X and is hard to do.</p>
  
  <p>If anyone knows how I can restart Finder in OS X (preferably Swift), please answer, even if it's just a link to some documentation or anything that will help me do this.</p>
  
  <p>Thanks!</p>