1
1
mirror of https://github.com/qvacua/vimr.git synced 2024-11-24 03:25:03 +03:00

Open cli pipe file as read-write

- When vimr is `Ctrl-C`'ed, then O_WRONLY hangs.
This commit is contained in:
Tae Won Ha 2018-07-01 14:27:56 +02:00
parent 018d3ee411
commit d50e027402
No known key found for this signature in database
GPG Key ID: E40743465B5B8B44

View File

@ -26,16 +26,18 @@ extension MainWindow {
self.set(dirtyStatus: false)
self.emit(self.uuidAction(for: .close))
if let cliPipePath = self.cliPipePath {
let fd = Darwin.open(cliPipePath, O_WRONLY)
guard fd != -1 else {
return
}
let handle = FileHandle(fileDescriptor: fd)
handle.closeFile()
_ = Darwin.close(fd)
guard let cliPipePath = self.cliPipePath, FileManager.default.fileExists(atPath: cliPipePath) else {
return
}
let fd = Darwin.open(cliPipePath, O_RDWR)
guard fd != -1 else {
return
}
let handle = FileHandle(fileDescriptor: fd)
handle.closeFile()
_ = Darwin.close(fd)
}
func set(title: String) {