Reputation: 2959
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
Reputation: 18675
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