RC_FIND_PIDS(3)

πŸ’– RC_FIND_PIDS(3) πŸ’–

okay bestie, so this is a page from the System Manager's Manual β€” yes we're in the big leagues now β€” and it's all about rc_find_pids, a lil function from the Run Command library (librc, link it with -lrc). she's giving process-hunting, she's giving detective energy, and honestly? obsessed. πŸ”βœ¨


πŸŽ€ NAME πŸŽ€

rc_find_pids β€” finds the pids of processes that match the given criteria

like. that's literally her whole job. finding pids. no notes. πŸ‘‘


🌸 LIBRARY 🌸

Run Command library (librc, -lrc)


✨ SYNOPSIS ✨

#include <rc.h>

RC_PIDLIST *
rc_find_pids(const char *const *argv, const char *cmd, uid_t uid,
    pid_t pid);

πŸ¦‹ DESCRIPTION πŸ¦‹

So rc_find_pids() returns an RC_PIDLIST β€” which is a structure based on the LIST macro from queue(3) β€” and it contains all the pids that matched your criteria. slay.

Now here's the tea on how it picks:

  • If you give it a pid, then only that pid comes back, and only if it's actually running. like, if it's not running, bestie, there's nothing to return. πŸ™ˆ
  • Otherwise, it checks all instances of argv with a process name of cmd owned by uid β€” and all of those are optional, so mix and match however you like.
⚠️ the returned list should be freed when you're done with it!! do NOT just leave it lying around, that's not the vibe. 🫢

πŸ’… IMPLEMENTATION NOTES πŸ’…

She's got range, okay? Different systems, different methods, same iconic results:

  • On BSD systems we use the Kernel Data Access Library (libkvm, -lkvm).
  • On Linux systems we use the /proc filesystem to find our processes.
🚨 IMPORTANT, no cap: each RC_PID should be freed in the list as well as the list itself when you're done. that's both. the pid and the list. free them. all of them. πŸ’€

🌈 SEE ALSO 🌈


πŸ‘‘ AUTHORS πŸ‘‘

Roy Marples <roy@marples.name>


mwah πŸ’‹ that's the whole page, bestie β€” go forth and find those pids. this was brought to you by OpenRC, dated Mar 17, 2008, and yes she's been serving since 2008 and she's still that girl. periodt. πŸ’–βœ¨πŸŽ€

πŸ“¦ where this page comes from