

In this example, we use the atty::is function and pass Stream::Stdin as an argument to check if stdin is a TTY. If it is, we proceed with blocking signals (block_signals), running the stardust-xr-server logic (run_stardust_xr_server), and unblocking signals afterwards (unblock_signals).
If stdin is not a TTY, we directly run the stardust-xr-server logic without blocking signals.
By conditionally handling signal blocking based on whether stdin is a TTY or not, you can ensure that signals are ignored when running stardust-xr-server from a shell while allowing normal signal handling when stardust-xr-server is not run from a TTY.

eclipseeclipseeclipsestardust-xr-serveristty()exec --help
exec: exec [-cl] [-a name] [command [argument ...]] [redirection ...]
Replace the shell with the given command.
Execute COMMAND, replacing this shell with the specified program.
ARGUMENTS become the arguments to COMMAND. If COMMAND is not specified,
any redirections take effect in the current shell.
Options:
-a name pass NAME as the zeroth argument to COMMAND
-c execute COMMAND with an empty environment
-l place a dash in the zeroth argument to COMMAND
If the command cannot be executed, a non-interactive shell exits, unless
the shell option `execfail' is set.
Exit Status:
Returns success unless COMMAND is not found or a redirection error occurs.use atty::Stream;
fn main() {
// Check if stdin is a TTY
let is_tty = atty::is(Stream::Stdin);
if is_tty {
// If stdin is a TTY, ignore signals and continue execution
block_signals();
run_stardust_xr_server();
unblock_signals();
} else {
// If stdin is not a TTY, proceed without blocking signals
run_stardust_xr_server();
}
}
fn block_signals() {
// Block signals
// ...
}
fn unblock_signals() {
// Unblock signals
// ...
}
fn run_stardust_xr_server() {
// Run your stardust-xr-server logic here
// ...
} if atty::is(atty::Stream::Stdin) {
stop_rx.await?;
} else {
tokio::select! {
biased;
_ = tokio::signal::ctrl_c() => (),
_ = stop_rx => (),
};
}
info!("Cleanly shut down event loop");
unsafe {
stereokit::sys::sk_quit();
}
Ok(())
}