473,769 Members | 2,044 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 2978
rahul <ra*********@gm ail.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.progr ammer, 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************ *************** *******@e4g2000 hsg.googlegroup s.com>,
rahul <ra*********@gm ail.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
5664
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, and if it does, remove the job from the queue and "do the job". This all seems quite doable using the synchronized Queue.py module and this page (http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/66012) which
3
2521
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
16307
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 signals correctly, in particular the SIGINT, preventing the application from stopping ungracefully. Indeed, I'd like to catch the signal, close everything in a consistent way and stop the application.
7
4242
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 methods directly? E.G.: 1) System Start - daemon class is instantiated and launched
2
1876
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 that something else can trigger it to wake up immediately. I can handle the wake-up code, it's the signalling that's giving me headaches - I'm not sure what the best way of doing it? Should I trap a certain signal sent to the process, (say...
3
5213
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 process, and it would only run as long as the real processes ran. I think this is a better way to stop gnuchess, as you are 100% sure, that it'll stop. Can you do this with popen?
1
11336
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 child thread sleeps for X seconds. All the while, the main thread loops forever doing its thing and also sleeps in between iterations (see the code at the end this message). Normally the application would be daemonized before the main
9
9149
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, -- Sakagami Hiroki
3
4290
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" (http://homepage.hispeed.ch/py430/ python/) on an Ubuntu linux pc. Everything works great EXCEPT... in the daemon script, there are two lines to change the uid & gid that the script runs as: os.setegid(10)
0
10215
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
9996
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9865
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8872
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7410
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6674
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5307
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5447
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3564
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.