Rust and Nix = easier Unix systems programming
kamalmarhubi.com
Rust and Nix = easier Unix systems programming
1–10 of 85 posts
Re: Rust and Nix = easier Unix systems programming
#2Re: Rust and Nix = easier Unix systems programming
#3pid_t childPid;
switch (childPid = fork()) {
case -1: ... /error handling /;
case 0: ... /Child Specific/
default: sleep (5); }
edit - seems to mangle formatting but something like that seems fairly clean.
Re: Rust and Nix = easier Unix systems programming
#4Minor nit pick but don't you typically do something like this in C pid_t childPid; switch (childPid = fork()) { case -1: ... / error handling /; case 0: ... / Child Specific / default: sleep (5); } edit - seems to mangle formatting but something like that seems fairly clean.
Great intro to Rust and Unix post!
Re: Rust and Nix = easier Unix systems programming
#5The function of kill is to kill a given pid, so there are two failure modes : "the pid didn't exist" or "the pid didn't die"
Re: Rust and Nix = easier Unix systems programming
#6Minor nit pick but don't you typically do something like this in C pid_t childPid; switch (childPid = fork()) { case -1: ... / error handling /; case 0: ... / Child Specific / default: sleep (5); } edit - seems to mangle formatting but something like that seems fairly clean.
In context, "typically" means your devops people get to work on Christmas to patch a critical CVE being actively exploited in the wild pissing off all your customers that one time someone didn't do the typical pattern anywhere in your codebase or the codebases of any of your 3rd party libaries, frameworks, applications...
Where "didn't do the typical pattern" might be if conditions as shown, or forgetting the "case -1", or missed a key and typed "case 1", or elided the "break;" from the case above (I note no "break;"s in your switch ;)), or didn't rtfm closely enough to see -1 was a special exit code, or mis-assumed kill(-1,...) was a noop, or ...
Re: Rust and Nix = easier Unix systems programming
#7Re: Rust and Nix = easier Unix systems programming
#8Minor nit pick but don't you typically do something like this in C pid_t childPid; switch (childPid = fork()) { case -1: ... / error handling /; case 0: ... / Child Specific / default: sleep (5); } edit - seems to mangle formatting but something like that seems fairly clean.
Re: Rust and Nix = easier Unix systems programming
#9Neat library, way too already-overloaded name.
Re: Rust and Nix = easier Unix systems programming
#10In reliability theory "X failed" is a poor error message. What we want to know is which failure mode has been triggered. The function of kill is to kill a given pid, so there are two failure modes : "the pid didn't exist" or "the pid didn't die"