Rex::Co...Process(3)

πŸ“¦ version 1.14.3, in nixos 26.05, nixpkgs unstable

πŸ’… Rex::Commands::Process β€” the glow-up

okay bestie, so this is the Rex::Co...Process(3) page (the actual module is Rex::Commands::Process, she's just going by a nickname in the header for ✨space reasons✨). User contributed perl documentation, we love to see it. Let's get into it 🫢


✨ NAME ✨

Rex::Commands::Process β€” process management commands. that's it, that's the whole vibe. πŸ’…


πŸ¦‹ DESCRIPTION πŸ¦‹

So with this module you can manage processes. Listing them, killing them, and so on. full main character energy for your process table honestly πŸ‘‘

heads up bestie: Version <= 1.0: All these functions will not be reported. and like, also β€” all these functions are not idempotent. not me repeating that three times in my head. no cap, do not assume running them twice gives you the same result. it does not. πŸ™ˆ

πŸŽ€ SYNOPSIS πŸŽ€

the little trailer, the vibe preview:

 kill $pid;
 killall "apache2";
 nice($pid, $level);

🌸 EXPORTED FUNCTIONS 🌸

here come the actual functions, alphabet-ish order, buckle in 🧚

πŸ’€ kill($pid, $sig)

Will kill the given process id. and if $sig is specified, it will kill with the given signal. that's the whole deal. periodt. ⭐

 task "kill", "server01", sub {
   kill 9931;
   kill 9931, -9;
 };

first one = polite little default kill. second one = -9, aka the "we're not asking anymore" signal. 😭πŸ”₯

🌈 killall($name, $sig)

Will kill the given process. If $sig is specified it will kill with the given signal. same energy as above but you're naming the process instead of the pid, iykyk πŸ’œ

 task "kill-apaches", "server01", sub {
   killall "apache2";
   killall "apache2", -9;
 };

πŸ” ps

List all processes on a system. and it will return all fields of a ps aux β€” every single one, she's generous πŸ’–

 task "ps", "server01", sub {
   for my $process (ps()) {
    say "command  > " . $process->{"command"};
    say "pid    > " . $process->{"pid"};
    say "cpu-usage> " . $process->{"cpu"};
   }
 };

and on most operating systems it is also possible to define custom parameters for ps() function. custom fields?? we stan a configurable queen ✨

 task "ps", "server01", sub {
   my @list = grep { $_->{"ni"} == -5 } ps("command","ni");
 };

This example would contain all processes with a nice of -5. (yes, exactly -5, keep the minus, it's load-bearing πŸ“)

🧚 nice($pid, $level)

Renice a process identified by $pid with the priority $level. it's giving "please calm down, bestie" but in scheduler terms πŸ’…

 task "renice", "server01", sub {
   nice (153, -5);
 };
friendly reminder: go back and re-read that DESCRIPTION bit β€” these functions are not idempotent, so don't go running them in a loop thinking it's a no-op. it is very much an op. 😭

🫢 and that's the page!

alright bestie, that's the whole thing. this page came to you from perl v5.42.3 and it's dated 2023-08-05 β€” so if you're reading this in the future, yes she's still serving, mwah πŸ’‹ bye! πŸŽ€

πŸ“¦ where this page comes from