Killing child daemon started by parent process

 
Thread Tools Search this Thread
Operating Systems Linux Red Hat Killing child daemon started by parent process
# 1  
Old 04-19-2010
Killing child daemon started by parent process

Hi All,

Hope this is right area to ask this question.

I have a shell script (bash) "wrapper.sh", which contains few simple shell command
which executes a "server.sh" (conatins code to execute a java server) as a daemon.

Now what I want to kill this "server.sh" so that the server should get shutdown.
What could be the way to kill this "server.sh".

Will killing "wrapper.sh" will automatically kill the "server.sh"?
Or I have to kill both this process?
Or By merely killing "server.sh" will automatically shutdown the server?

Few code and concepts will definitely be appreciated.

regards,
jw
# 2  
Old 04-19-2010
True daemons are independent of the parent.

I don't know why the parent is still running along with the "daemon", unless the daemon is not written correctly.

Anyway
Code:
kill -9 [pid of]daemon
kill -9 [pid of]wrapper

For more on a daemon:
Unix Programming Frequently Asked Questions - 1. Process Control
# 3  
Old 04-19-2010
thanks jim .....

In the mean time few more clarity on this issue ..............

--------------jserver-start.sh (Wrapper)-----------------
#!/bin/sh
#jserver-start.sh
sh /usr/jdserver/bin/jserver.sh > /dev/null 2>&1 &
------------------------------------------------------

Also, w.r.t your comments, the "-jserver-start.sh " will get killed automatically after spawing the daemon. right?

Here, the "jserver.sh" (The actual java Server), executes few code & then execute the the Java Server's Main class.

Also, I have a service (service-jserver.sh), which I placed in /etc/init.d (to run as a startup & running finely as a daemon while startup), having a "start" function, which actually calls this Wrapper Shell script (jserver-start.sh). Also, I have a "stop" function, which kill this process, by calling another shell script "jserver-stop.sh" & has the following code:
--------------jserver-stop.sh-------------------------
#!/bin/bash
#jserver-stop.sh
kill `ps -ef | grep jserver-start.sh | grep -v grep | awk '{ print $2 }'`
-----------------------------------------------------

Here, I would like to know which process shall I kill:
1.) The Wrapper (jserver-start.sh) Or 2.) Directly "jserver.sh" ?
But, while executing "service jserver-stop stop", it is not killing the service and the server is still running.

Any clue? Please suggest.

Last edited by jw_amp; 04-19-2010 at 03:30 PM..
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Solaris

Child killing parent process and how to set up SMF

Hello, A little background on what we are doing first. We are running several applications from a CLI, and not all of them are fully functional. They do on occasion core dump, not a problem. We are running a service that takes a screen scrape of those apps and displays them in a more user... (5 Replies)
Discussion started by: Bryan.Eidson
5 Replies

2. Shell Programming and Scripting

forking a child process and kill its parent to show that child process has init() as its parent

Hi everyone i am very new to linux , working on bash shell. I am trying to solve the given problem 1. Create a process and then create children using fork 2. Check the Status of the application for successful running. 3. Kill all the process(threads) except parent and first child... (2 Replies)
Discussion started by: vizz_k
2 Replies

3. Emergency UNIX and Linux Support

signal between parent process and child process

Hello, everyone. Here's a program: pid_t pid = fork(); if (0 == pid) // child process { execvp ...; } I send a signal (such as SIGINT) to the parent process, the child process receive the signal as well as the parent process. However I don't want to child process to receive the... (7 Replies)
Discussion started by: jackliang
7 Replies

4. Shell Programming and Scripting

[KSH/Bash] Starting a parent process from a child process?

Hey all, I need to launch a script from within 2 other scripts that can run independently of the two parent scripts... Im having a hard time doing this, if anyone knows how please let me know. More detail. ScriptA (bash), ScriptB (ksh), ScriptC (bash) ScriptA, launches ScriptB ScirptB,... (7 Replies)
Discussion started by: trey85stang
7 Replies

5. Shell Programming and Scripting

How to make the parent process to wait for the child process

Hi All, I have two ksh script. 1st script calls the 2nd script and the second script calls an 'C' program. I want 1st script to wait until the 'C' program completes. I cant able to get the process id for the 'C' program (child process) to make the 1st script to wait for the second... (7 Replies)
Discussion started by: sennidurai
7 Replies

6. UNIX for Advanced & Expert Users

Child Killing Parent

Hi all, I am writing a script which calls other third party scripts that perform numerous actions. I have no control over these scripts. My problem is, one of these scripts seems to execute and do what it is meant to do, but my calling / parent script always exits at that point. I need to... (4 Replies)
Discussion started by: mark007
4 Replies

7. Shell Programming and Scripting

Killing child process in ksh

I have a script that (ideally) starts tcpdump, sleeps a given number of seconds, then kills it. When I do this for 10 seconds or and hour, it works fine. When I try it for 10 hours (the length I actually want) it just doesn't die, and will actually stick around for days. Relevant part of my... (1 Reply)
Discussion started by: upnix
1 Replies

8. Shell Programming and Scripting

killing a child process

I am calling another script from my main script and making it run in the background,based upon the value of the input provided by the user I want to kill the child process ,I have written this code timer.ksh & PID=$$ print "\n Do you wish to continue .. (Y/N) : \c " read kill_proc if ]... (4 Replies)
Discussion started by: mervin2006
4 Replies

9. Programming

Child process is not getting started

Hi, When i m trying to run below code,its entering into wait stage. output: In parent pid=2134 // some random value assigned to child process parent waiting..... and then it keeps on waiting for child to get terminate Y this child is not getting... (5 Replies)
Discussion started by: Crab
5 Replies

10. Shell Programming and Scripting

killing a child process within a shell

Hi All, I have a written a script in korn shell for importing data into a oracle database. The shell invokes the import within the script. I want to kill this import (child process) . I tries using trap, but this does not kill the import even if i press cnt c. i have to login into other terminal... (2 Replies)
Discussion started by: yerics
2 Replies
Login or Register to Ask a Question