3 ms·
I found ctypes.sh to be legitimately useful for managing resources in nix-shell. E.g. flock a lock file and set CLOEXEC so that subprocesses don't hold the loc
by singron 7y ago
I found ctypes.sh to be legitimately useful for managing resources in nix-shell.
E.g. flock a lock file and set CLOEXEC so that subprocesses don't hold the lock open after the shell exits.
E.g. Use memfd_create to create a temp file and write a key. Then pass /proc/$$/fd/$FD to programs that need the key as a file. When the shell exits, the file can no longer be opened.
You can do similar things with traps, but they aren't guaranteed to execute, whereas these OS primitives will always be cleaned up.