forked from onivim/oni2
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Bugfix: Onivim 2 doesn't free up terminal when running (onivim#335)
* Create separate process launcher process to free terminal * Create logging infra for when running in detached mode * Formatting * Fix problematic logging * Formatting * Remove debug printing * Switch from print to using the log utility * Formatting * Fix error * Formatting * Fix for non-windows platforms * Formatting * Move close_on_exec after * Only allow printing if running in foreground * Formatting
- Loading branch information
Showing
15 changed files
with
144 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
/* | ||
* Oni2.re | ||
* | ||
* This is the launcher for the editor. | ||
*/ | ||
|
||
let stayAttached = ref(false); | ||
|
||
let version = () => { | ||
print_endline("Onivim 2 0.0.0"); | ||
}; | ||
|
||
let spec = [ | ||
("-f", Arg.Set(stayAttached), ""), | ||
("--nofork", Arg.Set(stayAttached), ""), | ||
("-version", Arg.Unit(version), ""), | ||
]; | ||
|
||
let anonArg = _ => (); | ||
|
||
let () = Arg.parse(spec, anonArg, "Usage: "); | ||
|
||
let executable = Sys.win32 ? "Oni2_editor.exe" : "Oni2_editor"; | ||
|
||
let startProcess = (stdio, stdout, stderr) => { | ||
let executingDirectory = Filename.dirname(Sys.argv[0]); | ||
Unix.create_process( | ||
executingDirectory ++ "/" ++ executable, | ||
Sys.argv, | ||
stdio, | ||
stdout, | ||
stderr, | ||
); | ||
}; | ||
|
||
let launch = () => | ||
if (stayAttached^) { | ||
let pid = startProcess(Unix.stdin, Unix.stdout, Unix.stderr); | ||
let _ = Unix.waitpid([], pid); | ||
(); | ||
} else { | ||
let (pstdin, stdin) = Unix.pipe(); | ||
let (stdout, pstdout) = Unix.pipe(); | ||
let (stderr, pstderr) = Unix.pipe(); | ||
|
||
let _ = startProcess(pstdin, pstdout, pstderr); | ||
|
||
Unix.set_close_on_exec(pstdin); | ||
Unix.set_close_on_exec(stdin); | ||
Unix.set_close_on_exec(pstdout); | ||
Unix.set_close_on_exec(stdout); | ||
Unix.set_close_on_exec(pstderr); | ||
Unix.set_close_on_exec(stderr); | ||
|
||
Unix.close(pstdin); | ||
Unix.close(pstdout); | ||
Unix.close(pstderr); | ||
}; | ||
|
||
launch(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
(ignored_subdirs (node_modules _esy)) | ||
|
||
(executable | ||
(name Oni2) | ||
(package Oni2) | ||
(public_name Oni2) | ||
(libraries unix) | ||
) |