See the following example:
$ proxychains-ng-http google-chrome >/dev/null 2>&1 &
[1] 2226205
$ wmctrl -lp | grep 'Google Chrome'
0x00400020 0 1458872 X10DAi-00 New Tab - Google Chrome
What's the relationship between 2226205 and 1458872? Is it possible
to find the PID of the application, i.e., 1458872, launched by
proxychains-ng based on the background proxychains-ng PID, i.e., 2226205?
See the following example:
$ proxychains-ng-http google-chrome >/dev/null 2>&1 & [1] 2226205 $
wmctrl -lp | grep 'Google Chrome' 0x00400020 0 1458872 X10DAi-00 New
Tab - Google Chrome
What's the relationship between 2226205 and 1458872? Is it possible
to find the PID of the application, i.e., 1458872, launched by
proxychains-ng based on the background proxychains-ng PID, i.e.,
2226205?
Regards, HY
In article <32c46650-de8a-4c4d-9a84-0bfdf31e979fn@googlegroups.com>, hongy...@gmail.com <hongyi.zhao@gmail.com> wrote:
See the following example:
$ proxychains-ng-http google-chrome >/dev/null 2>&1 &
[1] 2226205
$ wmctrl -lp | grep 'Google Chrome'
0x00400020 0 1458872 X10DAi-00 New Tab - Google Chrome
What's the relationship between 2226205 and 1458872? Is it possible
to find the PID of the application, i.e., 1458872, launched by
proxychains-ng based on the background proxychains-ng PID, i.e., 2226205?
I use the following shell function in my scripts:
# usage: childpid=$(getpid <parentPid> <program2search4>)
getpid() {
pstree -p $1 | gawk 'NF > 1 { print $2+0 }' FS="-($2)[(]"
}
The idea is that you could just use "pidof" (or "pgrep" or whatever), but that searches globally - i.e., searches all the processes on the system.
What you want is a version of "pidof" that only searches the children of a given process ID. The above function does that.
What's the advantage of the complex pstree-based function compared to
just using ps(1) ?
$ ps h --ppid 22575 -o pid
1764
31254
In article <shl07u$1amq$1@gioia.aioe.org>,
Janis Papanagnou <janis_papanagnou@hotmail.com> wrote:
...
What's the advantage of the complex pstree-based function compared to
just using ps(1) ?
$ ps h --ppid 22575 -o pid
1764
31254
A couple of things come to mind:
1) I think you and I read OP's requirements differently. So, we (you & I) seem to be solving different problems. Of course, only time will tell
which of us (if any) read it correctly.
2) ps is a mess. It has become such a joke over the years, trying to
support every possible version that's ever been written, that I try to
avoid it. I had no idea that any of the options you list above even
existed (and I've been using Unix and ps for far too long...)
On 12.09.2021 15:36, Kenny McCormack wrote:
In article <32c46650-de8a-4c4d...@googlegroups.com>,
hongy...@gmail.com <hongy...@gmail.com> wrote:
See the following example:
$ proxychains-ng-http google-chrome >/dev/null 2>&1 &
[1] 2226205
$ wmctrl -lp | grep 'Google Chrome'
0x00400020 0 1458872 X10DAi-00 New Tab - Google Chrome
What's the relationship between 2226205 and 1458872? Is it possible
to find the PID of the application, i.e., 1458872, launched by
proxychains-ng based on the background proxychains-ng PID, i.e., 2226205?
I use the following shell function in my scripts:
# usage: childpid=$(getpid <parentPid> <program2search4>)
getpid() {
pstree -p $1 | gawk 'NF > 1 { print $2+0 }' FS="-($2)[(]"
}
The idea is that you could just use "pidof" (or "pgrep" or whatever), but that searches globally - i.e., searches all the processes on the system. What you want is a version of "pidof" that only searches the children of a given process ID. The above function does that.What's the advantage of the complex pstree-based function compared to
just using ps(1) ?
$ ps h --ppid 22575 -o pid
1764
31254
On Sunday, September 12, 2021 at 9:44:35 PM UTC+8, Janis Papanagnou wrote:
On 12.09.2021 15:36, Kenny McCormack wrote:
In article <32c46650-de8a-4c4d...@googlegroups.com>,
hongy...@gmail.com <hongy...@gmail.com> wrote:
See the following example:
$ proxychains-ng-http google-chrome >/dev/null 2>&1 &
[1] 2226205
$ wmctrl -lp | grep 'Google Chrome'
0x00400020 0 1458872 X10DAi-00 New Tab - Google Chrome
What's the relationship between 2226205 and 1458872? Is it possible
to find the PID of the application, i.e., 1458872, launched by
proxychains-ng based on the background proxychains-ng PID, i.e., 2226205?
I use the following shell function in my scripts:
# usage: childpid=$(getpid <parentPid> <program2search4>)
getpid() {
pstree -p $1 | gawk 'NF > 1 { print $2+0 }' FS="-($2)[(]"
}
The idea is that you could just use "pidof" (or "pgrep" or whatever), but that searches globally - i.e., searches all the processes on the system. What you want is a version of "pidof" that only searches the children of aWhat's the advantage of the complex pstree-based function compared to
given process ID. The above function does that.
just using ps(1) ?
$ ps h --ppid 22575 -o pidThe wrapper script ``proxychains-ng-http'':
1764
31254
#!/usr/bin/env bash
proxychains_conf=/path/to/proxychains-ng-http.conf
if type -fp proxychains4 >/dev/null; then
exec proxychains4 -q -f $proxychains_conf "$@"
fi
The testing:
werner@X10DAi-00:~$ proxychains-ng-http google-chrome >/dev/null 2>&1 &
[1] 4069773
0x00400031 0 3657396 X10DAi-00 New Tab - Google Chrome
werner@X10DAi-00:~$ wmctrl -lp |grep -i 'chrome'
0x00400031 0 3657396 X10DAi-00 New Tab - Google Chrome
werner@X10DAi-00:~$ ps h --ppid 4069773 -o pid
werner@X10DAi-00:~$
Sysop: | Keyop |
---|---|
Location: | Huddersfield, West Yorkshire, UK |
Users: | 296 |
Nodes: | 16 (2 / 14) |
Uptime: | 69:37:29 |
Calls: | 6,655 |
Calls today: | 1 |
Files: | 12,200 |
Messages: | 5,332,101 |
Posted today: | 1 |