0

I'm writing console program. I want to launch vim from that program, wait until user exits it and continue execution.

  let editorTask = NSTask()
  editorTask.currentDirectoryPath = "/Users/vbezhenar/Documents"
  editorTask.launchPath = "/usr/bin/vim"
  editorTask.arguments = ["/Users/vbezhenar/Documents/file"]
  editorTask.launch()
  editorTask.waitUntilExit()

I'm running this program from terminal. I can see running vim with ps aux|grep vim in another terminal, but I don't see any vim user interface. Console just hangs until I press "Ctrl+C".

It seems like problem with stdout or stdin, but documentation clearly states that by default those file descriptors are inherited from launching process so there shouldn't be any problems. I don't alter environment either so it should inherit too.

I tried to launch "/bin/sh", it didn't work too.

vbezhenar
  • 11,148
  • 9
  • 49
  • 63
  • Your 'Users' path looks like Mac OSX. If that's what you're running maybe that's part of the problem. I know for instance vim exits incorrectly on OSX http://unix.stackexchange.com/questions/14497/why-would-vim-return-non-zero-exit-code-if-i-exit-immediately-after-opening – mddubs Oct 10 '14 at 18:19
  • Yes, it's OS X. I can execute /usr/bin/vim /Users/vbezhenar/Documents/file from Terminal and it works fine. – vbezhenar Oct 10 '14 at 18:31
  • I am facing the same issue. And 2017 now. Is there an explanation for this? – dawnstar Oct 26 '17 at 02:29

0 Answers0