473,385 Members | 2,162 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,385 software developers and data experts.

Delievering signals to daemon process

Hello all

I have written a chat server. It is invoked as follows -
$ ./server -start
It becomes a daemon. I want to implement a stop call-
$ ./server -stop
The approach I am following is to write the PID of the running server
in a flat file when server starts. When it needs to be stopped,
kill(SIGUSR1, pid) is sent to the server. The signal handler closes
all the open sockets and exits.

Your suggestions and alternate ways to accomplish it are welcome.

Regards,
Rahul
Feb 7 '08 #1
2 2945
rahul <ra*********@gmail.comwrote:
I have written a chat server. It is invoked as follows -
$ ./server -start
It becomes a daemon. I want to implement a stop call-
$ ./server -stop
Your suggestions and alternate ways to accomplish it are welcome.
My suggestion is to ask this in comp.unix.programmer, because this is a
rather system-specific thing to do, and they will probably tell you of a
doohicky in a Unix system library somewhere which will do precisely what
you want to do, but which is not ISO C.

Richard
Feb 7 '08 #2
In article <20**********************************@e4g2000hsg.g ooglegroups.com>,
rahul <ra*********@gmail.comwrote:
>Hello all

I have written a chat server. It is invoked as follows -
$ ./server -start
It becomes a daemon. I want to implement a stop call-
$ ./server -stop
The approach I am following is to write the PID of the running server
in a flat file when server starts. When it needs to be stopped,
kill(SIGUSR1, pid) is sent to the server. The signal handler closes
all the open sockets and exits.
kill() is not part of the standard C language. The only standard C
mechanism to send a signal is to use raise(), which only works
with respect to the current program. There is no standard C
mechanism to send a signal to another program.
>Your suggestions and alternate ways to accomplish it are welcome.
You can write a file into a fixed location, and have the second
program check the file periodically.
--
"There are some ideas so wrong that only a very intelligent person
could believe in them." -- George Orwell
Feb 7 '08 #3

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

Similar topics

3
by: Rob Hunter | last post by:
Hi all. I want to run a Python daemon that manages a "to-do" queue. I want it so that the daemon is always running, where its running consists of looking at the queue to see if it has any jobs,...
3
by: bmgx | last post by:
This is what I am trying to find out, instruction on how to create a simple daemon on unix systems(Linux), can't find any info on usual sources..
4
by: Gabriele Bartolini | last post by:
Hi, I am writing an application in C++ on Linux, using threads (this is my first experience with pthreads). The application itself is fine, it is just that I wanted to handle asynchronous...
7
by: Michael Ransburg | last post by:
Hi! I have implemented a daemon in C++. It runs all the time, between reboots. Is there a way for other C++ classes to get a reference to the instance of this daemon class in order to call its...
2
by: BigCalm | last post by:
I'm currently modifying a daemon (on AIX unix) which is primarily C source. At the moment, the daemon sleeps 30 seconds before checking if it has anything to do, but I'd like to improve this so...
3
by: Thomas Dybdahl Ahle | last post by:
Hi, I'm writing a program, using popen4(gnuchess), The problem is, that gnuchess keeps running after program exit. I know about the atexit module, but in java, you could make a process a daemon...
1
by: Chad J. Schroeder | last post by:
I've run into an "opportunity" in a Python application using threads and signals. Basically, there is a main process that spawns off a child thread that loops forever. In between iterations, the...
9
by: Sakagami Hiroki | last post by:
Hi, What is the easiest way to create a daemon process in Python? Google says I should call fork() and other system calls manually, but is there no os.daemon() and the like? Regards, --...
3
by: paul | last post by:
I am writing a daemon process that reads data from the serial port / dev/ttyS0. I am using pyserial & the method for setting up a daemon described in "Chris' Python Page"...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.