I want a simple command to list all the processes and its information from a given PGID.
I don't see a way to proactively tell
ps to select based on pgrp, so you have to request that column then filter on it; something like:
ps axo pgrp,stat,euid,ruid,tty,tpgid,sess,ppid,pid,pcpu,comm | awk -v pgrp=3668 '$1 == pgrp' ps -eo pgrp,pid,comm | sed -n -e 1p -e ' /3668/ p' PGRP=3668; ps -eo pgrp,pid,comm | sed -n -e 1p -e " / $PGRP / p"
ps -g $pgid does work as you ask.
On Linux, it doesn't work and you need to use some other solution, as has been suggested.
As an alternative that works on both, you can use
ps --ppid $ppid which lists all child processes of the given parent.
pgrep -ag PGID
0, it means pgrep's own process group, eg.
$ cat | cat | cat | pgrep -ag0 7301 cat 7302 cat 7303 cat
pgrep never includes itself in the listing, and
pkill never kills itself)