Closed GoogleCodeExporter closed 8 years ago
Good call on creating a ticket.
ps can be used to find any child pids...
ps --ppid $someParentPID
Though I figured there's probably a way to read out of the process table
directly...no?
Original comment by jpsut...@gmail.com
on 22 Aug 2008 at 1:49
That option to ps is unavailable on OS X.
I've never seen a portable C API for browsing the process table (that doesn't
mean
there isn't one).
The best alternative (I think) is to shell out to ps using POSIX-defined
options.
Original comment by bfrobin...@gmail.com
on 22 Aug 2008 at 10:11
This could be a bit difficult. The BSD version of ps has a set of options
(prefixed
with a "-" character), as does the Linux version. The Linux version will
accept the
BSD options but expects them to be passed without the "-" prefix. So, we could
use
the BSD options ("ps -j" [BSD] or "ps j" [Linux] may give us the information we
need), but we'd need to detect the particular *nix that we're running on to
adjust
the shell command appropriately.
I did a bit of reading on Linux's ps, and it (and top) uses a library called
"libproc" that reads the data directly from the /proc filesystem. Am I correct
in
assuming that the BSDs (and OS X) don't have /proc to read info from?
Original comment by jpsut...@gmail.com
on 23 Aug 2008 at 4:16
BSD ps will accept the options without the leading "-".
You are correct that /proc is Linux-specific. Some BSDs ship with procfs
support but
don't mount it by default. OS X appears to be completely out of luck.
OpenBSD has a ps that isn't setuid or setgid, with no procfs. I glanced through
their
source and found a function kvm_getprocs() that is … surprise … available
on OS X but
not on Linux.
Original comment by bfrobin...@gmail.com
on 23 Aug 2008 at 5:45
I've put some initial code in r188 to try using ps to detect weather the shell
pid is
in the foreground. As noted in the commit log, I suspect that BSD versions of
ps use
a different output format, so my output parsing may not be useful for anything
other
than Linux. Ben, can you test on OS X to see if this solution/hack is
effective there
too?
Original comment by jpsut...@gmail.com
on 6 Feb 2010 at 6:10
I've ported my hack to the QTermWidget branch, and it seems to work on Linux.
I
tested by having a copy of nano running the terminal and then without while
switching
tabs between two docs.
Original comment by jpsut...@gmail.com
on 23 Feb 2010 at 8:01
From what I've from testing this on Linux and OS X, I think the current
implementation works well enough for now. Not the most robust solution in the
world. If anyone comes up with a better solution, patches are welcome.
Original comment by jpsut...@gmail.com
on 22 Oct 2010 at 1:11
Original issue reported on code.google.com by
bfrobin...@gmail.com
on 22 Aug 2008 at 1:41