diff options
Diffstat (limited to 'users/Profpatsch/execline')
-rw-r--r-- | users/Profpatsch/execline/default.nix | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/users/Profpatsch/execline/default.nix b/users/Profpatsch/execline/default.nix index 47c7f8b74971..04d07895c682 100644 --- a/users/Profpatsch/execline/default.nix +++ b/users/Profpatsch/execline/default.nix @@ -39,10 +39,32 @@ let } ''; + setsid = depot.nix.writers.rustSimple + { + name = "setsid"; + dependencies = [ + depot.users.Profpatsch.execline.exec-helpers + depot.third_party.rust-crates.libc + ]; + } '' + use std::os::unix::ffi::OsStrExt; + use std::ffi::OsStr; + + fn main() { + let (args, prog) = exec_helpers::args_for_exec("setsid", 1); + let envvar = OsStr::from_bytes(&args.get(0).expect("first argument must be envvar name to set")); + let sid: i32 = unsafe { libc::setsid() }; + std::env::set_var(envvar, format!("{}", sid)); + let env: Vec<(&[u8], &[u8])> = vec![]; + exec_helpers::exec_into_args("getid", prog, env); + } + ''; + in depot.nix.readTree.drvTargets { inherit exec-helpers-hs print-one-env + setsid ; } |