Inv3r53
Inv3r53

Reputation: 2959

java process on linux

I have run a test java program on linux as a testuser as below.

su testuser -c "./java Test" &

When I see the processes, I see that there are 2 processes created. One as root and this spawns other one owned by testuser.

# ps -ef | grep Test
root     19684 19522  0 19:18 pts/0    00:00:00 su testuser -c ./java Test
testuser  19685 19684  1 19:18 pts/0    00:00:00 ./java Test
root     19699 19522  0 19:18 pts/0    00:00:00 grep Test

Why are 2 processes created here?

Even after I kill the process owned by root, the other one continues to run. Are there 2 java processes created here?

When I run my web app [ tomcat-spring ] as testuser I see only one process created. Why only one process here?

Upvotes: 2

Views: 704

Answers (1)

Andre Holzner
Andre Holzner

Reputation: 18675

  • the process with id 19684 is the su command you started.
  • the su process itself then starts the java process as a child process with a different userid
  • the third column in the output above is actually the parent process id from which you can see that the java process has the process 19684 (the su process) as parent

Killing the child process (19685) should make also the su process terminate (at least it does on my system).

Trying this on my system with sleep 3600 instead of java I see that when killing the su process, su also terminates (sends a signal to) the child process.

Upvotes: 3

Related Questions