473,669 Members | 2,421 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 2645
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*********@kde talk.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
11263
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 wrong with this script? Thanks, -- jv
8
2761
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 this would be simple enough if the ASP didn't have any user input, but it does.
7
6960
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 logged in my alert file for the shutdown or startup, however, the databases are down and when I manually start them up, the alert log reveals a crash recovery. I've verified the settings in the registry for automatic shutdown and startup. I've...
74
7958
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 a MySql shop or a Postgresql shop. It's my opinion that we should be using PG, because of the full ACID support, and the license involved. A consultant my company hired before bringing me in is pushing hard for MySql, citing speed and community...
2
11400
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, OpenProcessToken, LookupPrivilegeValue, AdjustTokenPrivilegese, ExitWindowsEx. I am trying to avoid using any API calls if possible and to use managed code instead. I couldn't find any easy way of doing this but searching the Internet with...
0
2141
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 and calls a C program (enigma.exe) to do the computations. enigma.exe should save its current state when receiving SIGINT or SIGTERM. This (obviously) works under Unix and also when running the script from the Windows command line and...
13
2677
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
27038
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 would do so by pinging the machine and seeing if I get a response). I would also like to add the ability to remotely shutdown a computer from the python script. Does anyone have a code snippet for pinging an IP, a code snippet for shutting down a...
3
8482
by: ktg024 | last post by:
How cain i shutdown the system
0
8465
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8383
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8895
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...
0
8809
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8658
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...
1
6210
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
4386
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2032
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1788
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.