LinuxQuestions.org
Did you know LQ has a Linux Hardware Compatibility List?
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices

Reply
 
LinkBack Search this Thread
Old 04-22-2008, 02:41 AM   #1
renjith.rv
LQ Newbie
 
Registered: Apr 2008
Posts: 2

Rep: Reputation: 0
how to signal a process from another process


Hello all,

I am working on two applications/processes. I need to signal the second process upon reaching a particular condition from process 1.
If anyone have idea about this, please share with me.

regards
renjith
 
Old 04-22-2008, 03:55 AM   #2
born4linux
Senior Member
 
Registered: Sep 2002
Location: Philippines
Distribution: Slackware, RHEL&variants, AIX, SuSE
Posts: 1,127

Rep: Reputation: 49
you can store the status of the condition in a var
and then echo that var in process 1.

then in process 2, you catch the var value from process 1
and use it.

example:

# process 1

# check if this_file.txt exists
if [ -f this_file.txt ]; then
echo "123"
else
echo "999"
fi
# eof process 1


# process 2
nRET=0

nRET=`/path/to/process1.sh`

case $nRET in
123)
echo "it is 123.";;
999)
echo "it is 999.";;
*)
echo "error."
esac
# end of process 2

in process 2, $nRET holds the value from process 1.

there's a more elegant way of doing it but the above works ok with
me.

hth.
 
Old 04-22-2008, 11:29 PM   #3
renjith.rv
LQ Newbie
 
Registered: Apr 2008
Posts: 2

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by born4linux View Post
you can store the status of the condition in a var
and then echo that var in process 1.

then in process 2, you catch the var value from process 1
and use it.

example:

# process 1

# check if this_file.txt exists
if [ -f this_file.txt ]; then
echo "123"
else
echo "999"
fi
# eof process 1


# process 2
nRET=0

nRET=`/path/to/process1.sh`

case $nRET in
123)
echo "it is 123.";;
999)
echo "it is 999.";;
*)
echo "error."
esac
# end of process 2

in process 2, $nRET holds the value from process 1.

there's a more elegant way of doing it but the above works ok with
me.

hth.
thank you very much for the information
 
Old 04-23-2008, 03:56 AM   #4
konsolebox
Senior Member
 
Registered: Oct 2005
Distribution: Gentoo, Slackware, LFS
Posts: 2,242
Blog Entries: 15

Rep: Reputation: 233Reputation: 233Reputation: 233
perhaps you can use signals and traps. in shell scripts, you can do this with the kill and trap commands.

do 'help kill' and 'help trap' for more info.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
how a father process know which child process send the signal SIGCHLD icoming Programming 10 07-20-2010 07:26 AM
Signal and process handling in linux Alpha_Beta_Gamma Linux - General 1 09-07-2007 09:34 PM
Process not killed with -KILL (-9) signal hondo Linux - General 2 07-25-2007 09:23 AM
Sending signal to child process DiAvOl Programming 6 05-16-2006 12:16 PM
Sending a signal to a process (Help me) rajesh_b Programming 2 09-17-2004 01:30 AM


All times are GMT -5. The time now is 05:03 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration