473,508 Members | 4,753 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

nice shutdown of CLI script by key press

Hi All!

I make command line script operating as demon and want to add
possibility to shutdown it from keyboard. I need to do some things at
shutdown moment. I can break script by Ctrl-break but in this case
destructors and registered shutdown functions are not called.
Is here any method to shutdown script from keyboard with destructors?
"Ctrl-break handler" or something like this?
Feb 4 '08 #1
4 2639
Alexey Kulentsov wrote:
I make command line script operating as demon and want to add
possibility to shutdown it from keyboard.
The most common way to kill daemons is to make them write their PIDs to a
file, then read the file and send a SIGKILL to that PID...

Keeping in mind that daemons run in the background, why do you want to shut
them down with a keystroke??

--
----------------------------------
Iván Sánchez Ortega -ivansanchez-algarroba-escomposlinux-punto-org-

Proudly running Debian Linux with 2.6.24-1-amd64 kernel, KDE 3.5.8, and PHP
5.2.5-2 generating this signature.
Uptime: 13:12:56 up 4 days, 23:57, 4 users, load average: 0.73, 0.53, 0.51

Feb 4 '08 #2
Iván Sánchez Ortega wrote:
Alexey Kulentsov wrote:
>I make command line script operating as demon and want to add
possibility to shutdown it from keyboard.

The most common way to kill daemons is to make them write their PIDs to a
file, then read the file and send a SIGKILL to that PID...

Keeping in mind that daemons run in the background, why do you want to shut
them down with a keystroke??
I want to do it without external utilites. And this script working in
background but with window where I can see log. OS Windows.
In any case - if I will "send a SIGKILL to that PID" that will be with
script? Is here called destructors in this case? If I kill it from task
manager PHP even have no time to reproduce bug #41350. :) Thanks!

Feb 4 '08 #3
Alexey Kulentsov wrote:
I want to do it without external utilites. And this script working in
background but with window where I can see log.
Then it isn't running in the background, and it's not a daemon.
OS Windows.
Then I urge you to use the win32service library.

http://php.net/manual/en/ref.win32service.php

Want to make a daemon? Then make your program behave like one.

--
----------------------------------
Iván Sánchez Ortega -ivansanchez-algarroba-escomposlinux-punto-org-

MSN:i_*************************@hotmail.com
Jabber:iv*********@jabber.org ; iv*********@kdetalk.net
Feb 4 '08 #4
Iván Sánchez Ortega wrote:
>
Then I urge you to use the win32service library.

http://php.net/manual/en/ref.win32service.php
Thanks, I didn't know about this extension.
>
Want to make a daemon? Then make your program behave like one.
No, really I want to make nice event-driven shutdown, and I afraid
it's impossible in PHP. Thanks in any case.

Feb 4 '08 #5

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

Similar topics

5
11226
by: j vickroy | last post by:
Hello, I'm trying to understand the behavior of the Python 2.3 logging module (MS Windows 2k) with regard to RotatingFileHandler. The following script illustrates a puzzling problem. What is...
8
2752
by: Jonathan Heath | last post by:
Hi all, I have created an ASP script that enters data into an Access Database. My problem is that I'd like this script to run when the computer is shutdown or the user logs off. I think...
7
6944
by: Lynn | last post by:
I'm running Oracle 8.1.7.4.1 on W2K and have the services for my oracle instances set to automatically startup and shutdown with the W2K server. Unfortunately, neither is working. Nothing gets...
74
7876
by: John Wells | last post by:
Yes, I know you've seen the above subject before, so please be gentle with the flamethrowers. I'm preparing to enter a discussion with management at my company regarding going forward as either...
2
11388
by: Brian Worth | last post by:
I have just upgraded from VB 4.0 to VB .NET 2002. One program under VB 4.0 was able to shut down or restart the (windows XP) machine using a series of API calls. (Getlasterror, GetCurrentProcess,...
0
2118
by: Stefan Krah | last post by:
Hello, I'm trying to run a Python script as a Windows service with a defined shutdown. The script (enigma-client.py) handles the communications with the server in a distributed computing effort...
13
2658
by: Thomas Mlynarczyk | last post by:
Hi, I have this code: class Test { public $status = 'dead'; function __construct() { $this->status = 'alive'; } function __destruct() { echo '<br>__destruct()'; } }
3
26977
by: joja15 | last post by:
I am working on a Python script to perform as a remote computer manager. So far I have a WOL function working and I would like to add the ability to show if a machine is on or off (I figured I...
3
8469
by: ktg024 | last post by:
How cain i shutdown the system
0
7228
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
7128
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7332
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
7502
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...
0
5635
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,...
1
5057
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...
0
4715
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...
0
1565
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
769
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.