Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C Programming > Using signals as a event driven framework

Reply
Thread Tools

Using signals as a event driven framework

 
 
jose luis fernandez diaz
Guest
Posts: n/a
 
      05-03-2004
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.
 
Reply With Quote
 
 
 
 
=?iso-8859-1?q?Nils_O=2E_Sel=E5sdal?=
Guest
Posts: n/a
 
      05-03-2004
On Mon, 03 May 2004 02:37:03 -0700, jose luis fernandez diaz wrote:

> 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

--
Nils Olav Selåsdal
System Engineer
w w w . u t e l s y s t e m s . c o m


 
Reply With Quote
 
 
 
 
Billy N. Patton
Guest
Posts: n/a
 
      05-03-2004
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.

jose luis fernandez diaz wrote:
> 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, http://www.velocityreviews.com/forums/(E-Mail Removed)

 
Reply With Quote
 
jose luis fernandez diaz
Guest
Posts: n/a
 
      05-03-2004
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.

Nils O. Selåsdal <(E-Mail Removed)> wrote in message news:<(E-Mail Removed)>...
> On Mon, 03 May 2004 02:37:03 -0700, jose luis fernandez diaz wrote:
>
> > 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

 
Reply With Quote
 
=?iso-8859-1?q?Nils_O=2E_Sel=E5sdal?=
Guest
Posts: n/a
 
      05-03-2004
On Mon, 03 May 2004 07:27:39 -0700, jose luis fernandez diaz wrote:

> 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..

--
Nils Olav Selåsdal
System Engineer
w w w . u t e l s y s t e m s . c o m


 
Reply With Quote
 
joe@invalid.address
Guest
Posts: n/a
 
      05-03-2004
(E-Mail Removed) (jose luis fernandez diaz) writes:

> 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
--
"Surprise me"
- Yogi Berra when asked where he wanted to be buried.
 
Reply With Quote
 
Xenos
Guest
Posts: n/a
 
      05-03-2004

"jose luis fernandez diaz" <(E-Mail Removed)> wrote in
message news:(E-Mail Removed) om...
> 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.



 
Reply With Quote
 
 
 
Reply

Thread Tools

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Event-driven framework (other than Twisted)? Phillip B Oldham Python 15 10-02-2008 11:02 AM
event driven framework for ruby snacktime Ruby 29 08-12-2005 05:57 PM
Event Driven in ASP.NET (Code Behind in VB.NET) Peri ASP .Net 6 08-08-2005 03:46 PM
Is there a standard data-driven desktop application framework John Chrisman Java 2 04-13-2004 12:59 PM
Event driven programing using Python Ben Kial Python 0 10-11-2003 11:42 PM



Advertisments