Live data from Hacker News

So, what can you do with a process ID?

will-keleher.com

11–20 of 26 posts

Re: So, what can you do with a process ID?

#11
post #2

Interesting there's no mention of the /proc filesystem ( https://docs.kernel.org/filesystems/proc.html ). cat /proc/ /environ would be a solid addition to this list.

Yep - a bunch of ways to read/use proc in arguably roundabout ways (things you may not be able to install)... but no mention of /proc

I use /proc/$PID/limits quite a bit in particular

Re: So, what can you do with a process ID?

#12
post #9

Earlier quoted context omitted.

This. (Combine with sudo too!) Now if I could just track NFS client traffic on a client associated with a PID (without having NFS server access). All I can get is all-PID/client-kernel data info vi nfsstat, nothing tying to a PID, filename, directory or inode to tell me which PID is causing all the NFS traffic!

iotop?

Tried it, I think the problem is the nfs io comes from the kernel and is not tied to a PID?

Re: So, what can you do with a process ID?

#13
post #3

And with strace -p pid you can somewhat "spy" on what a process is doing.

There us a hugely non-trivial (on the order of 100x) slowdown in code running when strace does its thing.

Brendan Gregg's work in the field of performance analysis (eBPF to the rescue) is quite useful in this regard, though not without tradeoffs (AFAIK: need compiler tools on the system to compile eBPF code).

Using `perf` may be a decent middle ground.

Re: So, what can you do with a process ID?

#14

  Way hay we're out of memory
  Way hay our disk is thrashing
  Way hay I need more coffee
  Early in the morning!

  What can you do with a process ID
  What can you do with a process ID
  What can you do with a process ID
  Early in the morning?

  Send a SIGKILL to its process
  Send a SIGKILL to its process
  Send a SIGKILL to its process
  Early in the morning!

Re: So, what can you do with a process ID?

#15
I know about some of these tricks. However, containers are popular and typically don’t have the tools installed, and you can’t necessarily sudo either. What do people replace these tricks with, in some cloud container or k8s pods?

Re: So, what can you do with a process ID?

#16
post #15

I know about some of these tricks. However, containers are popular and typically don’t have the tools installed, and you can’t necessarily sudo either. What do people replace these tricks with, in some cloud container or k8s pods?

If /proc is mounted in the container you can grab the same information (more tediously) by looking at /proc/

Re: So, what can you do with a process ID?

#18
post #14

Way hay we're out of memory Way hay our disk is thrashing Way hay I need more coffee Early in the morning! What can you do with a process ID What can you do with a process ID What can you do with a process ID Early in the morning? Send a SIGKILL to its process Send a SIGKILL to its process Send a SIGKILL to its process Early in the morning!

Love it, couldn't help but sing!

Re: So, what can you do with a process ID?

#19
Could have written disclaimer in the 'kill -HUP' example that they should be only sent when it is known that the destination process will handle it, as the default for most signals is to terminate the process.

Especially since every other example is non-destructive...

Re: So, what can you do with a process ID?

#20
Annoyingly, what you can't always do is use it to uniquely identify a process. After a process exits, its PID can be reused. On Linux this (by default) only happens after PID 32767 is assigned, but generally it's implementation-defined. A rare edge case, of course, but it can have security implications.
Post reply on HN