pid(n)

πŸ“¦
version 9.0.3 Β· 3 versions
, in alpine 3.23, alpine 3.24, fedora 43, fedora 44, nixos 26.05, nixpkgs unstable

✨ pid(n) β€” the "who even are you" command πŸ’…

ok bestie so Tcl has a built-in command called pid and it's literally the process-identifier girlie. it's part of Tcl Built-In Commands, and yes she's been around since forever (iykyk). let's get into it 🫢


🌸 SYNOPSIS 🌸

pid ?fileId?

πŸ’– DESCRIPTION πŸ’–

okay so here's the tea. pid has two moods and honestly? both slay.

If you pass the fileId argument, bestie, it should normally refer to a process pipeline β€” you know, the kind you made with the open command. In that case pid gives you back a list, and the elements of that list are the process identifiers of all the processes in the pipeline, in order. every single one. no skips. πŸŽ€

but wait β€” if fileId refers to an open file that is not a process pipeline? the list comes back empty. not a crisis, just the vibe. πŸ’€

If you give it no fileId argument at all? then pid just returns the process identifier of the current process. it's giving main character energy, honestly.

and here's the important bit bestie: all process identifiers are returned as decimal strings. not ints, not vibes, strings. periodt. ✨


πŸ¦‹ EXAMPLE πŸ¦‹

ok so the goal here: print process info about the processes in a pipeline using the SysV ps program, before reading the output of that pipeline. so iconic of us.

set pipeline [open "| zcat somefile.gz | grep foobar | sort -u"]
# Print process information
exec ps -fp [pid $pipeline] >@stdout
# Print a separator and then the output of the pipeline
puts [string repeat - 70]
puts [read $pipeline]
close $pipeline

like?? we open the pipeline, we ask pid who's in it, we hand that straight to ps, we print a cute lil separator, then we read the goods. obsessed. πŸ’œ


πŸ‘‘ SEE ALSO πŸ‘‘


πŸ”₯ KEYWORDS πŸ”₯

file, pipeline, process identifier


ok that's the whole page bestie, go forth and identify some processes πŸ’…βœ¨

this one's from the Tcl era, dated 7.0, and it's pid(n) β€” manual page girlie forever πŸŽ€

πŸ“¦ where this page comes from