473,320 Members | 1,965 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Using signals as a event driven framework

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.
Nov 14 '05 #1
6 2864
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
Nov 14 '05 #2
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 <NO*@Utel.no> wrote in message news:<pa****************************@Utel.no>...
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

Nov 14 '05 #3
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, b-******@ti.com

Nov 14 '05 #4
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
Nov 14 '05 #5
joe
jo**********************@yahoo.es (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.
Nov 14 '05 #6

"jose luis fernandez diaz" <jo**********************@yahoo.es> wrote in
message news:c2**************************@posting.google.c 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.

Nov 14 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: alanrn | last post by:
For all you seasoned VB programmers this is going to be a no brainer. However, as a C programmer learning VB I'm having trouble getting my arms around the event-driven nature of VB. Suppose I...
7
by: pysim | last post by:
Hi, I have a couple of general requests for pointers to python examples and design advice. I'm looking for examples of MVC-based GUI controls done in python (model-view-controller). Also,...
12
by: Charles Law | last post by:
This is a bit of a vague question, but I am just starting on this, and wonder if anyone has ideas of where to start. I have a program that controls some external equipment. It sends messages in...
19
by: Kamilche | last post by:
I have looked at many object-oriented programming frameworks out there for C. Though the ideas presented are intriguing, and I've used some of them in my own work, they all suffered some drawback...
11
by: Jackie | last post by:
Hi everyone, I'd like to know when and how signals are used (e.g. SIGFPE, SIGABRT, SIGTERM, SIGSEGV, SIGINT)? Thank you so much.
4
by: Michael D. Ober | last post by:
In VB 6 and MFC, the socket classes support event driven architectures such that when data arrives, the data arrival event is fired and you can process the code. Is there a similar method in VB...
1
by: Anonieko | last post by:
Understanding and Using Exceptions (this is a really long post...only read it if you (a) don't know what try/catch is OR (b) actually write catch(Exception ex) or catch{ }) The first thing I...
11
by: vippstar | last post by:
What is the purpose of signals and why do they exist in C? thanks in advance
15
by: Phillip B Oldham | last post by:
Are there any python event driven frameworks other than twisted?
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.