How to get the id of a very short child process if the parent is known?

TheMeaningfulEngineer

I'm looking for a way to get the PID of a short child process in Linux. The process is instant from a human perspective. I know the parent process which will spawn the child process.

Is there a way to log information about all the processes that are created by a specific parent process?

I'm not looking for a way to retroactively figure out the PID of the child but a way to log it once it happens.

Stéphane Chazelas

You could use the audit system:

sudo auditctl -a exit,always -S execve -F ppid="$pid"

would cause audit entries to be generated each time a child of $pid executes a command. audit.log would have things like:

type=SYSCALL msg=audit(1373986729.977:377): arch=c000003e syscall=59 success=yes exit=0 a0=7ff000e4b188 a1=7ff000e4b1b0 a2=7fff928d47e8 a3=7fff928caac0 items=2 ppid=7502 pid=691 auid=10031 uid=10031 gid=10031 euid=10031 suid=10031 fsuid=10031 egid=10031 sgid=10031 fsgid=10031 ses=1 tty=pts5 comm="echo" exe="/bin/echo" key=(null)
type=EXECVE msg=audit(1373986729.977:377): argc=2 a0="/bin/echo" a1="test"
type=CWD msg=audit(1373986729.977:377):  cwd="/tmp"
type=PATH msg=audit(1373986729.977:377): item=0 name="/bin/echo" inode=131750 dev=fe:00 mode=0100755 ouid=0 ogid=0 rdev=00:00

Where you can find the pid amongst other things.

If you're interested in processes that don't necessarily execute something, you can add audit rules for the fork and clone system calls.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

How to get environmental variables of a very short process?

From Java

How to get child process from parent process

From Dev

How to get the ID of a child when mouseover parent

From Dev

How to get the ID of a child when mouseover parent

From Dev

How to get a nested list of a child by Parent id?

From Dev

Nodejs how to get child process from process Id

From Dev

Using Debugger how to get child process's PID from Parent

From Dev

After starting process, how to get parent's PID in the child?

From Dev

How to get the child nodes of a parent and process it with jquery ajax

From Dev

How to get the child nodes of a parent and process it with jquery ajax

From Dev

Using Debugger how to get child process's PID from Parent

From Dev

If you fork() and exec() from the child process, and wait in the parent, how does the parent get a return code from the child?

From Dev

How to know if a process is a parent or a child

From Dev

Process parent ID of child process is different from PID of parent

From Dev

How to get the parent div id from the anchor child

From Dev

How to get child table rows using parent table ID?

From Dev

How to get all descendent child process id of pid in c in linux

From Dev

How to get parent process ID using objective c in OS X?

From Dev

Get child list of parent process in C

From Dev

Open the process is the process ID is known

From Dev

How to debug child and parent process using windbg?

From Dev

How to wait for parent process to exit in a child?

From Dev

Get child process operation result from parent process

From Dev

How can child kill parent process while parent process waits until child process to terminate?

From Dev

Supposed to get the child but somehow gets the parent ID

From Dev

get child id from parent javascript onclick

From Dev

get the id of parent tr for a child td

From Dev

get the parent and child id of js tree

From Dev

How to get all child process's PIDs when given the parent PID in C

Related Related

  1. 1

    How to get environmental variables of a very short process?

  2. 2

    How to get child process from parent process

  3. 3

    How to get the ID of a child when mouseover parent

  4. 4

    How to get the ID of a child when mouseover parent

  5. 5

    How to get a nested list of a child by Parent id?

  6. 6

    Nodejs how to get child process from process Id

  7. 7

    Using Debugger how to get child process's PID from Parent

  8. 8

    After starting process, how to get parent's PID in the child?

  9. 9

    How to get the child nodes of a parent and process it with jquery ajax

  10. 10

    How to get the child nodes of a parent and process it with jquery ajax

  11. 11

    Using Debugger how to get child process's PID from Parent

  12. 12

    If you fork() and exec() from the child process, and wait in the parent, how does the parent get a return code from the child?

  13. 13

    How to know if a process is a parent or a child

  14. 14

    Process parent ID of child process is different from PID of parent

  15. 15

    How to get the parent div id from the anchor child

  16. 16

    How to get child table rows using parent table ID?

  17. 17

    How to get all descendent child process id of pid in c in linux

  18. 18

    How to get parent process ID using objective c in OS X?

  19. 19

    Get child list of parent process in C

  20. 20

    Open the process is the process ID is known

  21. 21

    How to debug child and parent process using windbg?

  22. 22

    How to wait for parent process to exit in a child?

  23. 23

    Get child process operation result from parent process

  24. 24

    How can child kill parent process while parent process waits until child process to terminate?

  25. 25

    Supposed to get the child but somehow gets the parent ID

  26. 26

    get child id from parent javascript onclick

  27. 27

    get the id of parent tr for a child td

  28. 28

    get the parent and child id of js tree

  29. 29

    How to get all child process's PIDs when given the parent PID in C

HotTag

Archive