473,587 Members | 2,505 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to call on terminate function in perl

40 New Member
Hi.,

I want to call some function when the user force to terminate the perl program.

For example.,
I write a program to create a file when the program starts...
Also I need to delete a file when the user force to terminate the process

i.e Calling some function when the user hitting Ctrl+C in perl command prompt..

Looking for Ur suggestions.

Thanks.
May 2 '08 #1
5 2743
numberwhun
3,509 Recognized Expert Moderator Specialist
Hi.,

I want to call some function when the user force to terminate the perl program.

For example.,
I write a program to create a file when the program starts...
Also I need to delete a file when the user force to terminate the process

i.e Calling some function when the user hitting Ctrl+C in perl command prompt..

Looking for Ur suggestions.

Thanks.
I think I know what you are asking to do, but I don't know if its possible or how to do it. Hopefully one our experts will have an answer for you.

Regards,

Jeff
May 6 '08 #2
KevinADC
4,059 Recognized Expert Specialist
I'm not sure how wise this is but using a simple example:

Expand|Select|Wrap|Line Numbers
  1. local $SIG{INT} = sub { print "good-bye\n"; exit(0); };
  2. while (1){
  3. print "hello\n";
  4. sleep(2);
  5. }
  6.  
I would read up on signals more and see what the perl documentation has to suggest. A place to start:

http://perldoc.perl.org/perlipc.html
May 6 '08 #3
cnsabar
40 New Member
I'm not sure how wise this is but using a simple example:

Expand|Select|Wrap|Line Numbers
  1. local $SIG{INT} = sub { print "good-bye\n"; exit(0); };
  2. while (1){
  3. print "hello\n";
  4. sleep(2);
  5. }
  6.  
I would read up on signals more and see what the perl documentation has to suggest. A place to start:

http://perldoc.perl.org/perlipc.html
Hi Kevin,

Thanks for your help and suggestion.,
Using the above logic,
Now I can able to produce the expected output in my program.

Thanks,
May 7 '08 #4
cnsabar
40 New Member
By Using this function , its works fine when the I press Ctrl + C
But it wont reflect anything when I close the command prompt using close icon on the right corner of the window.



Hi Kevin,

Thanks for your help and suggestion.,
Using the above logic,
Now I can able to produce the expected output in my program.

Thanks,
May 24 '08 #5
KevinADC
4,059 Recognized Expert Specialist
I don't know.
May 25 '08 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

1
19340
by: sam | last post by:
I have a function writen in Perl that takes a name-value list (array) as argument and returns a name-value list (array). My question is: How to call this function from PHP and get the returned name-value list in PHP variable? Thanks.
5
68811
by: Randell D. | last post by:
Folks, I feel like pulling my hair out - I tried unsuccessfully over the past few days to install ImagMagick but because of version conflicts and missing libraries I had to give up. I originally choose ImageMagick because I've heard so much about it. I then decided to go with the inbuilt GD tools since I'm using PHP 4.3.3 that I compiled...
2
4571
by: Jakub Moscicki | last post by:
Hello, A small problem: I get a signal during a system call (from xmlrpclib -> httplib) and an exception "IOError: Interrupted system call" is raised (this is system dependant, on other machine it does not raise this exception). I have my own signal handler so I want to simply ignore this exception if it occures. But for a reason...
1
3205
by: Mark Ohlund | last post by:
I'm trying to use the PDL modules to perform a Vector Space search as shown in: http://www.perl.com/pub/a/2003/02/19/engine.html I'm running FreeBSD 4.9 w/ Perl 5.6.1 and 2.4.1 of PDL. The source code for the search is: http://www.perl.com/2003/02/19/examples/VectorSpace.pm I'm calling this with the following code:
3
13769
by: Keith Grefski | last post by:
I cant seem to figure out how to terminate a process in vb.net i can do it using vbscript and wmi but terminate doesnt seem to exist in the available classes for wmi under vb.net
7
6797
by: archana | last post by:
Hi all, I am having application in which i am doing asynchronous call.I am using manualresetevent to wait for asynchronous call to complete. I want to stop asynchronous call after certain period of time. I want something like thread.abort for aborting aynchronous call. Can someone tell me way of aborting asynchronous call.
2
4064
by: Mark Cummings | last post by:
I am migrating an Oracle 9i to Oracle 10g database, and Perl 5.0.4 to Perl 5.8.7 in Sun Solaris environment. Using Perl 5.8.7, the following legacy code segment is returning a '-1' return code on the system call to execute the 'mv' command. Note that the mv request is across directories. sub move_inproc { print "sub move_inproc\n"; ...
2
2496
by: cnsabar | last post by:
Hi., I am using the following code to terminate the any process by giving the process name as input... use Win32::Process::List; use Win32::OLE; $Win32::OLE::Warn = 3; $P = Win32::Process::List->new(); print "Enter the process name.exe to terminate: ";
0
1687
by: cnsabar | last post by:
Hi., I need a Perl script to terminate the any running process in server. by specifying computer name and process name.. I have the following code to terminate the any process by specifying the process name in the local system... use Win32::Process::List; use Win32::OLE;
0
7923
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...
0
7852
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...
0
8216
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. ...
0
8349
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...
0
8221
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...
1
5719
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...
0
5395
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...
0
3845
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...
1
2364
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 we have to send another system

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.