3 fix column order mismatch (thanks Sergei Nikiforov)
source | link

You can list all processes in a given group by filtering the output of ps.

ps -e -o pid,pgid,pid | awk -v p=1234 '$1 == p {print $2}'

There's no ps option to directly filter by PGID, probably because it isn't useful very often.

What ps does under the hood doesn't really matter.

This is not atomic, unlike kill -- -1234. But even if there was a way to atomically list processes in a process group, what good would it be? By the time you process the list, it may be incomplete or include processes that are dead and whose PID has been reused.

To do anything useful with the set of processes in a process group, the kernel would have to expose an interface that performs the action, not just an interface that lists the members of the group. The only such interface is to send a signal to the processes.

You can list all processes in a given group by filtering the output of ps.

ps -e -o pid,pgid | awk -v p=1234 '$1 == p {print $2}'

There's no ps option to directly filter by PGID, probably because it isn't useful very often.

What ps does under the hood doesn't really matter.

This is not atomic, unlike kill -- -1234. But even if there was a way to atomically list processes in a process group, what good would it be? By the time you process the list, it may be incomplete or include processes that are dead and whose PID has been reused.

To do anything useful with the set of processes in a process group, the kernel would have to expose an interface that performs the action, not just an interface that lists the members of the group. The only such interface is to send a signal to the processes.

You can list all processes in a given group by filtering the output of ps.

ps -e -o pgid,pid | awk -v p=1234 '$1 == p {print $2}'

There's no ps option to directly filter by PGID, probably because it isn't useful very often.

What ps does under the hood doesn't really matter.

This is not atomic, unlike kill -- -1234. But even if there was a way to atomically list processes in a process group, what good would it be? By the time you process the list, it may be incomplete or include processes that are dead and whose PID has been reused.

To do anything useful with the set of processes in a process group, the kernel would have to expose an interface that performs the action, not just an interface that lists the members of the group. The only such interface is to send a signal to the processes.

2 list all processes, not just the ones in the current session (thanks Todd Freed)
source | link

You can list all processes in a given group by filtering the output of ps.

ps -e -o pid,pgid | awk -v p=1234 '$1 == p {print $2}'

There's no ps option to directly filter by PGID, probably because it isn't useful very often.

What ps does under the hood doesn't really matter.

This is not atomic, unlike kill -- -1234. But even if there was a way to atomically list processes in a process group, what good would it be? By the time you process the list, it may be incomplete or include processes that are dead and whose PID has been reused.

To do anything useful with the set of processes in a process group, the kernel would have to expose an interface that performs the action, not just an interface that lists the members of the group. The only such interface is to send a signal to the processes.

You can list all processes in a given group by filtering the output of ps.

ps -o pid,pgid | awk -v p=1234 '$1 == p {print $2}'

There's no ps option to directly filter by PGID, probably because it isn't useful very often.

What ps does under the hood doesn't really matter.

This is not atomic, unlike kill -- -1234. But even if there was a way to atomically list processes in a process group, what good would it be? By the time you process the list, it may be incomplete or include processes that are dead and whose PID has been reused.

To do anything useful with the set of processes in a process group, the kernel would have to expose an interface that performs the action, not just an interface that lists the members of the group. The only such interface is to send a signal to the processes.

You can list all processes in a given group by filtering the output of ps.

ps -e -o pid,pgid | awk -v p=1234 '$1 == p {print $2}'

There's no ps option to directly filter by PGID, probably because it isn't useful very often.

What ps does under the hood doesn't really matter.

This is not atomic, unlike kill -- -1234. But even if there was a way to atomically list processes in a process group, what good would it be? By the time you process the list, it may be incomplete or include processes that are dead and whose PID has been reused.

To do anything useful with the set of processes in a process group, the kernel would have to expose an interface that performs the action, not just an interface that lists the members of the group. The only such interface is to send a signal to the processes.

1
source | link

You can list all processes in a given group by filtering the output of ps.

ps -o pid,pgid | awk -v p=1234 '$1 == p {print $2}'

There's no ps option to directly filter by PGID, probably because it isn't useful very often.

What ps does under the hood doesn't really matter.

This is not atomic, unlike kill -- -1234. But even if there was a way to atomically list processes in a process group, what good would it be? By the time you process the list, it may be incomplete or include processes that are dead and whose PID has been reused.

To do anything useful with the set of processes in a process group, the kernel would have to expose an interface that performs the action, not just an interface that lists the members of the group. The only such interface is to send a signal to the processes.