The io context member is also used on Linux.
#ushell-cherrypick of 33627971 by Johan.Berg
#rb johan.berg
[CL 33628176 by johan berg in ue5-main branch]
Add option in UnrealTraceServer to detach from current console. Automatically apply this option when launching a forked server to avoid stopping the process when terminal window closes.
#rb ionut.matasaru
[CL 33572073 by johan berg in ue5-main branch]
* Adds command line argument for setting sponsor mode "--sponsor-mode".
* Added additional information in command line help regarding settings.
#rb ionut.matasaru
[CL 33228090 by johan berg in ue5-main branch]
If UTS was launched by a process with elevated privileges and provided as a sponsor process, UTS was not able to open a handle to the sponsor which resulted in immediate exit. We only need the exit status of the process so opening the sponsor with PROCESS_QUERY_LIMITED_INFORMATION is enough.
#jira UE-210097
#rb ionut.matasaru
[CL 32542069 by johan berg in ue5-main branch]
When UTS was looking for the users home directory getpwuid was used. In certain scenarios this doesn't work and a null pointer is returned. Man pages suggest reading the HOME environment variable is more correct, so with this change we use that primarily and fall back to getpwuid method.
#jira UE-208979
#rb ionut.matasaru
#ushell-cherrypick of 32243446 by Johan.Berg
[CL 32244934 by johan berg in ue5-main branch]
* Move sponsor process check inside store and use asio tasks to check, instead of launching separate thread on Linux/Mac. There was some strange interaction between standalone pthreads and asio.
* How checking is done is now platform independent, but some platform specific code is needed to trigger exit events.
#jira UE-204157
#rb ionut.matasaru
[CL 31126135 by johan berg in ue5-main branch]
* The sig_timedwait function was used to listen for signals and regularly check sponsor processes. However this function is not available on MacOS. Changed the daemon function to use the old signal listening method but add a worker thread that checks the sponsors at regular intervals instead. Send SIGUSR2 when exit is desired.
* Moved log output from Lifetime to Main to avoid spamming when sponsored mode is disabled. Note that we still need to call ShouldKeepAlive in that mode in order to poll the sponsored pid queue in instance info.
* During development there were cases where the shared memory remained despite the instance dissapearing. Added check if the reported pid is actually still alive. There are false positives here if pid was reused.
* On MacOS it's only possible to resize shared memory once. Added code to verify it's only called once.
[CL 30841356 by johan berg in ue5-main branch]
In extreme cases (for example user starting server + multiple local clients) all tracing at the exact time the number of command slots might be too small. Bump the number of sponsor command slots to 128 and add a retry in the process that adds commands.
#rb ionut.matasaru
[CL 30287932 by johan berg in ue5-main branch]
Adds new sponsor mode of running server. In this mode the server must be started with a parent pid. New pids can be added by running `unrealtraceserver fork --sponsor [pid]`. When all sponsor processes have exited and there are no active connections the server will exit. Most of the lifetime management logic is located in the new Lifetime type, but actual querying and exiting is done in the respective main functions.
Linux and Mac implementation was using a lock file to communicate running pid and version to other instances. With this change all platforms now use shared memory mapping techniques.
Command line options and command parsing has also been refactored and is now parsed and passed to all main functions. Command line help is also added.
#rb ionut.matasaru
[CL 30176867 by johan berg in ue5-main branch]
Prepare for future work by breaking out logging and instance info into separate files.
#rb ionut.matasaru
[CL 29987825 by johan berg in ue5-main branch]
Whenever settings would change we deleted the directory watches for all mounts. On Mac each watcher had a dispatch queue with running jobs. When the those lingering jobs would get callbacks, it would try to access the existing mount instance which would have been deleted.
#rb none
#jira UE-187849
[CL 27992508 by johan berg in ue5-main branch]
UTS was relying on standard library file times to get a common epoch based timestamp. However for Linux this does not seem to produce reliable results, so we fall back to the posix interface functions.
#rb martin.ridgers
#jira UE-191462
[CL 27784647 by johan berg in ue5-main branch]