473,385 Members | 1,730 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.

How to call on terminate function in perl

40
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 2726
numberwhun
3,509 Expert Mod 2GB
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 Expert 2GB
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
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
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 Expert 2GB
I don't know.
May 25 '08 #6

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

Similar topics

1
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...
5
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...
2
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...
1
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...
3
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
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...
2
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...
2
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 =...
0
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...
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:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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.