diff options
| author | Stefan Boberg <[email protected]> | 2024-08-14 16:20:32 +0200 |
|---|---|---|
| committer | GitHub Enterprise <[email protected]> | 2024-08-14 16:20:32 +0200 |
| commit | 92066c19239422e9c09c4ccd46d42fd573ce6853 (patch) | |
| tree | 26b307053e4b4a3b116a05b46834f35ff38f8d7e /src/zenserver/xmake.lua | |
| parent | updated Lucas-C/pre-commit-hooks to v1.3.1 to fix compilation on MacOS (#114) (diff) | |
| download | zen-92066c19239422e9c09c4ccd46d42fd573ce6853.tar.xz zen-92066c19239422e9c09c4ccd46d42fd573ce6853.zip | |
added `--detach` option to zenserver (#115)
added `--detach` option to zenserver. When this is passed in with a false value, we do not create a new process group in order to behave more as expected when running with `xmake run zenserver`. Without this change the zenserver process does not receive any signals and won't exit when xmake does, causing processes to linger in the background.
The default behaviour (when run from UE) is unchanged.
Diffstat (limited to 'src/zenserver/xmake.lua')
| -rw-r--r-- | src/zenserver/xmake.lua | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/src/zenserver/xmake.lua b/src/zenserver/xmake.lua index c42f305ee..a3d7aa124 100644 --- a/src/zenserver/xmake.lua +++ b/src/zenserver/xmake.lua @@ -68,3 +68,31 @@ target("zenserver") -- line below forces breakpad_client to be to the right of sentry_native add_syslinks("breakpad_client") end + + -- to work around some unfortunate Ctrl-C behaviour on Linux/Mac due to + -- our use of setsid() at startup we pass in `--no-detach` to zenserver + -- ensure that it recieves signals when the user requests termination + on_run(function(target) + -- the following is roughly cribbed from xmake/actions/run/xmake.lua + -- it would be nicer if we had the option of amending the arguments + -- via before_run for instance, but I can't figure out a way to do that + import("core.base.option") + + -- get the run directory of target + local rundir = target:rundir() + + -- get the absolute target file path + local targetfile = path.absolute(target:targetfile()) + + -- get run arguments + local args = table.wrap(option.get("arguments") or target:get("runargs")) + + table.insert(args, "--detach=false") + + -- debugging? + if option.get("debug") then + debugger.run(targetfile, args, {curdir = rundir}) + else + os.execv(targetfile, args, {curdir = rundir, detach = option.get("detach")}) + end + end) |