Skip to content

Commit

Permalink
fvr remote ok.
Browse files Browse the repository at this point in the history
  • Loading branch information
Yatao Li committed Nov 16, 2020
1 parent 2cc0ed1 commit 248e7a8
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
3 changes: 3 additions & 0 deletions common.fs
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,9 @@ let newProcess prog args stderrenc =
let p = new Process()
p.StartInfo <- psi
p.EnableRaisingEvents <- true
// in case the parent crashed and we happen to be running Windows(tm)...
// TODO need further investigation.
ignore <| AppDomain.CurrentDomain.ProcessExit.Subscribe(fun _ -> p.Kill(true))
p

[<AutoOpen>]
Expand Down
8 changes: 2 additions & 6 deletions daemon.fs
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@ type Session =
// Some=Exclusively connected
server: NamedPipeServerStream option
proc: Process
// in case the daemon crashed and we happen to be running Windows(tm)...
killHandle: IDisposable
exitHandle: IDisposable
}

Expand All @@ -34,10 +32,11 @@ let FVR_MAGIC = [| 0x46uy ; 0x56uy ; 0x49uy ; 0x4Duy |]

let inline private trace x = trace "daemon" x

let pipeaddrUnix x = "/tmp/CoreFxPipe_" + x
let pipeaddr x =
if RuntimeInformation.IsOSPlatform(OSPlatform.Windows)
then @"\\.\pipe\" + x
else "/tmp/CoreFxPipe_" + x
else pipeaddrUnix x

let pipename = sprintf "fvr_%s"

Expand All @@ -58,19 +57,16 @@ let newSession nvim stderrenc args svrpipe =
let paddr = pipeaddr pname
let args = "--headless" :: "--listen" :: paddr :: args
let proc = newProcess nvim args stderrenc
let killHandle = AppDomain.CurrentDomain.ProcessExit.Subscribe(fun _ -> proc.Kill(true))
let session =
{
id = myid
server = Some svrpipe
proc = proc
killHandle = killHandle
exitHandle = proc.Exited |> Observable.subscribe(fun _ ->
// remove the session
trace "Session %d terminated" myid
sessions.[myid].exitHandle.Dispose()
sessions.Remove(myid) |> ignore
killHandle.Dispose()
proc.Dispose()
)
}
Expand Down
3 changes: 2 additions & 1 deletion neovim.fs
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,8 @@ type Nvim() =
RemoteSession pipe
| FVimRemote(pipe, Remote(prog, args), verb, _) ->
let pname = Option.defaultValue defaultDaemonName pipe
let paddr = pipeaddr pname
let paddr = pipeaddrUnix pname
trace "Connecting to remote fvr session '%s'" paddr
let proc = newProcess prog (args @ [paddr]) Text.Encoding.UTF8
proc.Start() |> ignore
fvrConnect proc.StandardInput.BaseStream verb
Expand Down

0 comments on commit 248e7a8

Please sign in to comment.