Using signals as a event driven framework

  • Thread starter jose luis fernandez diaz
  • Start date
J

jose luis fernandez diaz

Hi,

I have a C program running in background in UNIX. From a shell script
I want to notify it some events. The easiest way to do it is through
signals, but it is not correct because signal are not a event drivent
framework. Can anyone give me other straightforward solution ?

Thanks,
Jose Luis.
 
?

=?iso-8859-1?q?Nils_O=2E_Sel=E5sdal?=

Hi,

I have a C program running in background in UNIX. From a shell script
I want to notify it some events. The easiest way to do it is through
signals, but it is not correct because signal are not a event drivent
framework. Can anyone give me other straightforward solution ?
Signals can du fine, and you can very well make it event driven.
However signals have ofcourse limitations, you can only use a few of them,
and it's hard to pass additional data.
A common approach is to use unix sockets, see e.g. and create a little
utility that can communicate to the "server" for use in e.g. shell
scripts.
see e.g. http://www.ecst.csuchico.edu/~beej/guide/ipc/usock.html
 
B

Billy N. Patton

ANother simple approach I use to signal programs running
is to have a directory /me/SIGNALS
Withing that directory I put files(empty) by a particular name.
The running program does an open dir on every loop and check for the
existance of files by name ?*. If this file exists, I unlink it and
continue as if I had caught a signal.

Very simple and limited. But you can signal a program with ANY file
name. Not just the signals supplied by your system.
Hi,

I have a C program running in background in UNIX. From a shell script
I want to notify it some events. The easiest way to do it is through
signals, but it is not correct because signal are not a event drivent
framework. Can anyone give me other straightforward solution ?

Thanks,
Jose Luis.


--
___ _ ____ ___ __ __
/ _ )(_) / /_ __ / _ \___ _/ /_/ /____ ___
/ _ / / / / // / / ___/ _ `/ __/ __/ _ \/ _ \
/____/_/_/_/\_, / /_/ \_,_/\__/\__/\___/_//_/
/___/
Texas Instruments ASIC Circuit Design Methodlogy Group
Dallas, Texas, 214-480-4455, (e-mail address removed)
 
J

jose luis fernandez diaz

This solution forces to write a C client program. In this case a
prefer to use a CORBA communication framework. Anyway, is there
another way to comunicate directly from the shell to a background
proccess without a client program ?

Thanks,
Jose Luis.
 
?

=?iso-8859-1?q?Nils_O=2E_Sel=E5sdal?=

This solution forces to write a C client program. In this case a
prefer to use a CORBA communication framework. Anyway, is there
Ugh. big and bloated corba. I'd rather take SunRPC over domain
sockets for such purposes.
Depending ofcourse on what you need to communicate back and
forth to the server the C program wouldn't be very many lines.
another way to comunicate directly from the shell to a background
proccess without a client program ?
You can create a named pipe, have the server read from that, and the
client write to it (a shell script can easily write to a named pipe)
Or listen on a ip socket, and implement some text protocol (e.g. http)
and script it with netcat or similar.
Thinking about it netcat or a similar tool can probably connect
to a unix domain socket as well..
 
J

joe

This solution forces to write a C client program. In this case a
prefer to use a CORBA communication framework. Anyway, is there
another way to comunicate directly from the shell to a background
proccess without a client program ?

CORBA? That's better than a short C program?

If you're using ksh, you can use coprocesses, run the C program that
way, and you can just write to its stdin. For example, in ksh:

#! /bin/ksh
echoprog |&
print -p "this is a test"
read -p echoline
echo $echoline
printf "%s\n" "$echoline"

where "echoprog" is some program that just echos back what it reads
from stdin. Adjust accordingly.

Joe
 
X

Xenos

jose luis fernandez diaz said:
This solution forces to write a C client program. In this case a
prefer to use a CORBA communication framework. Anyway, is there
another way to comunicate directly from the shell to a background
proccess without a client program ?

Thanks,
Jose Luis.
CORBA is extreme overkill of such a small problem.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top