You mean the shell script eventually hangs, because it runs an I/O command that eventually hangs?
Then, in the shell script, define a timeout function like this:
and run the critical I/O commands like this example
The call to perl is needed to install an alarm signal handler.
#!/bin/csh
# This program will add integers
#
#
# add integer1 ..
#
# Check for argument
if ($#argv == 0 ) then
echo "usage: add integers"
exit 1
else
set input = $argv
endif
#
set sum = 0
foreach var ( $input )
@sum = $sum + $input
end
# (1 Reply)
Sorry for all the threads. I am almost done. I ahve a bash script that is launching a diags program then copying the .html over my client. then it does the following line
/opt/firefox/firefox report.html
it launches it fines but the program waits for me to close the window or kill the script.... (2 Replies)
Hi,
Could anybody please let me know how to call a C_Program
from shell script. I know through command "system" we can call
shell script from C program.
Awaiting response.
Thanks and regards,
Chanakya M (4 Replies)
Hi,
If I have a large shell script running as root, say for example like one that copies a ton of files, how would I kill the shell script and any processes that it created?
Thanks (7 Replies)
Hi there, im new too shell scripting and was wondering if it is possible to create a shell script to take in a variable and load a c program.
My C program is a file monitor, and is started by using the terminal and using to following code
./monitor FileToBeMonitored
is it possible to have... (12 Replies)
Hi,
I am trying to automate the killing of named processes of which I found a good solution here on the forums but as I am pretty much a begginer to linux I am having an issue. The code I found is:
kill $(ps -ef | nawk '/monitoreo start/ { print $2}'}
but what I want to do is replace... (3 Replies)
shell script in Unix/Linux to find the lines numbers of a text file are having word which is 5 to 10 characters long and having first letter as a capital letter. (3 Replies)
Hi I am new in programming.
I have written a shell code, but i want to secure my code.
I have tried SHC. It is converting it to binary, but can be converted in plain text again by core dump.
I have tried to convert it in rpm by "rpmbuild -bb my.spec" option but the result is same.
... (4 Replies)
Hi all,
I am trying to write a shell script that starts a program, reads from its stdout and can write to its stdin.
I'm having trouble to get it to work, I tried using named pipes, and using exec and file descriptors.
Just couldn't get it to work, so I thought I'll post it here to see if... (4 Replies)
Discussion started by: test it
4 Replies
LEARN ABOUT DEBIAN
mail::spamassassin::timeout
Mail::SpamAssassin::Timeout(3pm) User Contributed Perl Documentation Mail::SpamAssassin::Timeout(3pm)NAME
Mail::SpamAssassin::Timeout - safe, reliable timeouts in perl
SYNOPSIS
# non-timeout code...
my $t = Mail::SpamAssassin::Timeout->new({ secs => 5, deadline => $when });
$t->run(sub {
# code to run with a 5-second timeout...
});
if ($t->timed_out()) {
# do something...
}
# more non-timeout code...
DESCRIPTION
This module provides a safe, reliable and clean API to provide alarm(2)-based timeouts for perl code.
Note that $SIG{ALRM} is used to provide the timeout, so this will not interrupt out-of-control regular expression matches.
Nested timeouts are supported.
PUBLIC METHODS
my $t = Mail::SpamAssassin::Timeout->new({ ... options ... });
Constructor. Options include:
secs => $seconds
time interval, in seconds. Optional; if neither "secs" nor "deadline" is specified, no timeouts will be applied.
deadline => $unix_timestamp
Unix timestamp (seconds since epoch) when a timeout is reached in the latest. Optional; if neither secs nor deadline is specified,
no timeouts will be applied. If both are specified, the shorter interval of the two prevails.
$t->run($coderef)
Run a code reference within the currently-defined timeout.
The timeout is as defined by the secs and deadline parameters to the constructor.
Returns whatever the subroutine returns, or "undef" on timeout. If the timer times out, "$t-<gt"timed_out()> will return 1.
Time elapsed is not cumulative; multiple runs of "run" will restart the timeout from scratch. On the other hand, nested timers do
observe outer timeouts if they are shorter, resignalling a timeout to the level which established them, i.e. code running under an
inner timer can not exceed the time limit established by an outer timer. When restarting an outer timer on return, elapsed time of a
running code is taken into account.
$t->run_and_catch($coderef)
Run a code reference, as per "$t-<gt"run()>, but also catching any "die()" calls within the code reference.
Returns "undef" if no "die()" call was executed and $@ was unset, or the value of $@ if it was set. (The timeout event doesn't count
as a "die()".)
$t->timed_out()
Returns 1 if the most recent code executed in "run()" timed out, or "undef" if it did not.
$t->reset()
If called within a "run()" code reference, causes the current alarm timer to be restored to its original setting (useful after our
alarm setting was clobbered by some underlying module).
perl v5.14.2 2011-06-06 Mail::SpamAssassin::Timeout(3pm)