pid(3tcl)

πŸ“¦
version 9.0.4 Β· 2 versions
, in debian trixie, ubuntu questing, ubuntu resolute, ubuntu stonking

πŸ’– pid β€” bestie, who even ARE you (process edition) πŸ’–

okay so this is a page from the Tcl Built-In Commands manual, and it's called pid. Yes, like process identifier. Yes, it's short. Yes, it's iconic. Let's go ✨


🌸 NAME 🌸

pid β€” Retrieve process identifiers 🫢


✨ SYNOPSIS ✨

pid ?fileId?

πŸ’… DESCRIPTION πŸ’…

okay so here's the tea, bestie πŸ“

If you hand over the fileId argument, then β€” and this is the important part β€” it should normally refer to a process pipeline that got created with the open command. In that case, pid is gonna return a list whose elements are the process identifiers of all the processes in the pipeline, in order. Like, in ORDER order. The way it lines them up?? obsessed. πŸ‘‘

And lowkey, if fileId refers to an open file that is not a process pipeline, the list will just be empty. No drama, just vibes. πŸ’€

But if you don't give a fileId argument at all? Then pid returns the process identifier of the current process. That's you. That's your main character energy right there. 🌟

Oh and β€” all process identifiers are returned as decimal strings. Not numbers, not vibes, decimal strings. Periodt. πŸ’…


πŸŽ€ EXAMPLE πŸŽ€

So here's how you print process information about the processes in a pipeline using the SysV ps program, before you read the output of that pipeline. Chef's kiss setup fr fr 😭

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?? the way that pipeline just works?? πŸ¦‹


πŸ‘‘ SEE ALSO πŸ‘‘


🌈 KEYWORDS 🌈

file, pipeline, process identifier


no cap, that's the whole page bestie. short, sweet, and literally does exactly what it says on the tin. iykyk πŸ’œ

and that's a wrap on this lil page from the Tcl manual, version 7.0, dated 7.0 (yes that's what the footer says, don't come for me πŸ™ˆ). bye bestie, go check on your processes πŸ’–βœ¨

πŸ“¦ where this page comes from