For a program I am designing, which involves handling the keyboard input Ctrl^c (SIGINT), it is taking ages for the program to actually recognise and perform the corresponding action whenever I run it and hit Ctrl^C at the CL. I have to do at least 3 Ctrl^Cs before the program will actually register and handle SIGINT appropriately.
Currently Im using signal() to map the various types of unix signals (i.e SIGINT, SIGSTSP) to handler functions I have defined in my program. What the handler functions do is call exit(0) (which quits the program) whenever the corresponding signal has been received by the program. As I mentioned before, it is taking several Ctrl^Cs to get the handler functions to be invoked, when it should just be 1 Ctrl^C.
Im unsure what could be causing my problem. Please feel free to make any suggestions.
Ive actually solved my own problem, however I will still post up the code (sorry for not doing it earlier) and how I solved it for anyone who is interested
This is basically how I do my signal mapping
This is SigHandler()
A design requirement was for me to get the program to check under a network drive if a certain directory existed. To fulfill this requirement, I made my program call the find command from the shell via system(). When I was assembling the shell command, I put /mnt/ in front of the disk I wished to search.
Strangely enough, when I removed /mnt/ from the command string, the search time was reduced and the program ran a lot faster (It wasn't running as fast before). Unfortuntately though Ctrl^C was still not responding in the desired timespan, however Ctrl^Z (SIGTSTP) was. I ended up axing signal(SIGINT, SigHandler); altogether and my problem was solved.
At some point in the future, Id still like to be able to get Ctrl^C to respond a lot faster as using Ctrl^C to terminate a unix-based command or program is more well-known. I think that Ctrl^Z should still be reserved strictly for the suspending process
Allow (do not allow) keyboard interrupts to kill a process that is hung while waiting for a response on a hard-mounted file system. The default is intr, which makes it possible for clients to interrupt applications that can be waiting for a remote mount.
The following command will run and wait for input from the user.
/usr/sap/SAP/webdisp/wdispmon pf=/usr/sap/SAP/webdisp/profile
What I would like to do is (in one command):
- Add the above line to a ksh script
- Receive the output
- and send a SIGINT
I have seen many posts on how to... (3 Replies)
Hi all,
i am trying to process a list of values in FILE like this:
aaa:bbb
ccc:ddd
eee:fff
With the following logic:
for INFO in FILE
do
export F1=`cut -f1,3,5,7 -d":" < FILE`
export F2=`cut -f2,3,5,7 -d":" < FILE`
ssh $F1 bash <<EOF
echo $F1
echo $F2
date (10 Replies)
I can get this working, but if something is down I get an error and the script does not move on. I can not get the "else" function working. What might I be doing wrong?
use SNMP::Simple
my %ios = ();
$list="list.list";
open(DAT, $list) || die("Can't Open List");
@raw_data=<DAT>;... (4 Replies)
hi friends i have a problem in signal handling ...
let me explain my problem clearly..
i have four process ..
main process forks two child process and each child process again forks another new process respectively...
the problem is whenever i kill the child process it is reforking and the... (2 Replies)
i wrote handler for sigsegv such that i can allocate memory for a variable to which
sigsegv generated for illlegal acces of memory.
my code is
#include <signal.h>
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
char *j;
void segv_handler(int dummy)
{
j=(char *)malloc(10);
... (4 Replies)
Hi all,
I have this method to read a string from a STDIN:
void readLine(char* inputBuffer){
fgets (inputBuffer, MAX_LINE, stdin);
fflush(stdin);
/* remove '\n' char from string */
if(strlen(inputBuffer) != 0)
inputBuffer = '\0';
}
All work fine but if i... (1 Reply)
Hi,
I have an application.xml file like
</dependency>
<artifactId>_AdminServicesEAR</artifactId>
<version>1.0.0-20080521.085352-1</version>
<context-root>oldvalue</context-root>
<type>ear</type>
<DOCTYPE "abc/xyz/eft">
<NewTag>value123</xyz>
... (4 Replies)
Hi,
I am opening a file......then i am wrting some data into it......and i am reopening the file again but ......i get a error cannot open file.......
$::file= "\adder\testfile.txt"
open(TEST1,$::file);
some write operation
close(TEST1)
open(TEST1,$::file) 'I GET A ERROR CAN OPEN... (2 Replies)
Hi All,
i am running a oracle procedure which writes a file . The same file is picked up by another script which runs in a cron after every 5 minutes.
Now the problem is that sometimes my script picks up a file while the procedure is still writing data in the file.
is there is any way i... (4 Replies)