I need help with SIGIO and the terminal..


 
Thread Tools Search this Thread
Top Forums UNIX for Advanced & Expert Users I need help with SIGIO and the terminal..
# 1  
Old 10-29-2009
I need help with SIGIO and the terminal..

I want write a program where I call the pause() function to wait for any signal. Now I have registered the SIGIO signal with the following lines of code:

const int on = 1;

fcntl(STDIN_FILENO,F_SETOWN,getpid());

ioctl(STDIN_FILENO, FIOASYNC, &on);
ioctl(STDIN_FILENO, FIONBIO, &on);

signal(SIGIO,catchSIGIO);

then I called the pause() function. The body of the catchSIGIO() is given below:

void catchSIGIO(int num){
printf("INSIDE SIGIO\n");
}

The program compiles alright. When I run the program, it halts/pauses at the pause() function call. Then when I type something in the keyboard, the SIGIO signal is NOT generated (I guess) because nothing happens. The program remains stuck at the pause() function. I can ONLY get out by pressing ctrl+C.

But I want to detect ANY KEY PRESS by SIGIO signal or any other signal (if there is any).

Can anyone help me on this issue? Thanks in advance.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Print Terminal Output Exactly how it Appears in the Terminal to a New Text File

Hello All, I have a text file containing output from a command that contains lots of escape/control characters that when viewed using vi or view, looks like jibberish. But when viewed using the cat command the output is formatted properly. Is there any way to take the output from the cat... (7 Replies)
Discussion started by: mrm5102
7 Replies

2. Shell Programming and Scripting

Cannot get terminal application to launch with a graphical launcher when successful in terminal

I have been having an extremely annoying problem. For the record, I am relatively new at this. I've only been working with unix-based OS's for roughly two years, mostly Xubuntu and some Kali. I am pretty familiar with the BASH language, as that's the default shell for debian. Now, I've made this... (16 Replies)
Discussion started by: Huitzilopochtli
16 Replies

3. UNIX for Dummies Questions & Answers

A terminal controlling a terminal...

Hi all... Consider me a dummy here... I do not want any code or for anyone to show me how to do it at this time, but here is the question:- I have had this brainstorm to be able to control the AudioScope.sh program in the "Shell Scripting And Programming" forum... Is it possible, by... (4 Replies)
Discussion started by: wisecracker
4 Replies

4. UNIX for Dummies Questions & Answers

Does DOS has a terminal or pseudo terminal?

I am wondering if the DOS console works like the unix terminal? (1 Reply)
Discussion started by: vistastar
1 Replies

5. UNIX for Dummies Questions & Answers

Gnuplot wxt terminal vs x11 terminal

Hi, I installed ubuntu recently on my pc. And I installed gnuplot as well. When I first started working with gnuplot it was working . I did a plot and when I wanted to fit my data something happened and not the default terminal of gnuplot is xwt! I changed it to: set terminal x11, but it... (0 Replies)
Discussion started by: cosmologist
0 Replies

6. UNIX for Advanced & Expert Users

Pseudo-terminal will not be allocated because stdin is not a terminal.

I am trying to automate a SSH login using Keys using the following command ssh -i id_rsa usernamw@ipaddr. I am successful in doing this and i am getting the Warning Screen and I logon successfully. but when I am executing the command tail -1cf put.dat | ssh -i id_rsa username@ipaddr > get.dat ... (1 Reply)
Discussion started by: Shivdatta
1 Replies

7. UNIX for Dummies Questions & Answers

Terminal

Hello, I'm completely new to UNIX, and as part of a project I'm doing at university I am using a UNIX SOLAR computer. I have been told to SSH tunnel to access it, using Putty and VNC, which I have done and works. When I could then 'see' the computer from home I had a terminal open, but I was... (10 Replies)
Discussion started by: Jono_H
10 Replies

8. AIX

Terminal

People, what util can help me as a terminal for COM connection with a Zyxel modem so that I can connect to another server (p630) with the same modem through a dedicated line??? And also does anybody know where can I put a question about Storage Area Networking?? I am having problems with setting... (5 Replies)
Discussion started by: dilshik
5 Replies

9. UNIX for Dummies Questions & Answers

terminal

Hi there, Does anyone know what exactly is the different between a terminal and a console ? My understanding is a console is normally a local session while a terminal can be a remote as well. What do you think guys? Thanks (1 Reply)
Discussion started by: guest100
1 Replies

10. UNIX for Advanced & Expert Users

connecting to unix through hyper terminal - as a dumb terminal

I just changed from windows NT to XP and I am no longer able to connect to my unix system. I used to use hyper terminal -- which acts as dumb terminal to my main frame unix system. I think one of the options used to be "direct to comX". This option isn't listed now. I use a serial port and the... (2 Replies)
Discussion started by: michelle
2 Replies
Login or Register to Ask a Question
aioread(3AIO)						Asynchronous I/O Library Functions					     aioread(3AIO)

NAME
aioread, aiowrite - read or write asynchronous I/O operations SYNOPSIS
cc [ flag ... ] file... -laio [ library... ] #include <sys/types.h> #include <sys/asynch.h> int aioread(int fildes, char *bufp, int bufs, off_t offset, int whence, aio_result_t *resultp); int aiowrite(int fildes, const char *bufp, int bufs, off_t offset, int whence, aio_result_t *resultp); DESCRIPTION
The aioread() function initiates one asynchronous read(2) and returns control to the calling program. The read continues concurrently with other activity of the process. An attempt is made to read bufs bytes of data from the object referenced by the descriptor fildes into the buffer pointed to by bufp. The aiowrite() function initiates one asynchronous write(2) and returns control to the calling program. The write continues concurrently with other activity of the process. An attempt is made to write bufs bytes of data from the buffer pointed to by bufp to the object refer- enced by the descriptor fildes. On objects capable of seeking, the I/O operation starts at the position specified by whence and offset. These parameters have the same meaning as the corresponding parameters to the llseek(2) function. On objects not capable of seeking the I/O operation always start from the current position and the parameters whence and offset are ignored. The seek pointer for objects capable of seeking is not updated by aioread() or aiowrite(). Sequential asynchronous operations on these devices must be managed by the application using the whence and offset parameters. The result of the asynchronous operation is stored in the structure pointed to by resultp: int aio_return; /* return value of read() or write() */ int aio_errno; /* value of errno for read() or write() */ Upon completion of the operation both aio_return and aio_errno are set to reflect the result of the operation. Since AIO_INPROGRESS is not a value used by the system, the client can detect a change in state by initializing aio_return to this value. The application-supplied buffer bufp should not be referenced by the application until after the operation has completed. While the opera- tion is in progress, this buffer is in use by the operating system. Notification of the completion of an asynchronous I/O operation can be obtained synchronously through the aiowait(3AIO) function, or asynchronously by installing a signal handler for the SIGIO signal. Asynchronous notification is accomplished by sending the process a SIGIO signal. If a signal handler is not installed for the SIGIO signal, asynchronous notification is disabled. The delivery of this instance of the SIGIO signal is reliable in that a signal delivered while the handler is executing is not lost. If the client ensures that aiowait() returns nothing (using a polling timeout) before returning from the signal handler, no asynchronous I/O notifications are lost. The aiowait() function is the only way to dequeue an asynchronous notification. The SIGIO signal can have several meanings simultaneously. For example, it can signify that a descriptor generated SIGIO and an asynchronous operation completed. Further, issuing an asynchronous request successfully guarantees that space exists to queue the completion notification. The close(2), exit(2) and execve(2)) functions block until all pending asynchronous I/O operations can be canceled by the system. It is an error to use the same result buffer in more than one outstanding request. These structures can be reused only after the system has completed the operation. RETURN VALUES
Upon successful completion, aioread() and aiowrite() return 0. Upon failure, aioread() and aiowrite() return -1 and set errno to indicate the error. ERRORS
The aioread() and aiowrite() functions will fail if: EAGAIN The number of asynchronous requests that the system can handle at any one time has been exceeded EBADF The fildes argument is not a valid file descriptor open for reading. EFAULT At least one of bufp or resultp points to an address outside the address space of the requesting process. This condition is reported only if detected by the application process. EINVAL The resultp argument is currently being used by an outstanding asynchronous request. EINVAL The offset argument is not a valid offset for this file system type. ENOMEM Memory resources are unavailable to initiate request. USAGE
The aioread() and aiowrite() functions have transitional interfaces for 64-bit file offsets. See lf64(5). ATTRIBUTES
See attributes(5) for descriptions of the following attributes: +-----------------------------+-----------------------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | +-----------------------------+-----------------------------+ |MT-Level |Safe | +-----------------------------+-----------------------------+ SEE ALSO
close(2), execve(2), exit(2), llseek(2), lseek(2), open(2), read(2), write(2), aiocancel(3AIO), aiowait(3AIO), sigvec(3UCB), attributes(5), lf64(5) SunOS 5.10 22 Mar 2004 aioread(3AIO)