Help answer threads with 0 replies.
Go Back > Forums > Linux Forums > Linux - General
User Name
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.


  Search this Thread
Old 10-27-2003, 06:17 AM   #1
LQ Newbie
Registered: Oct 2003
Posts: 2

Rep: Reputation: Disabled
Control stdin buffering

Hi folks,

i want to practice a little C programming and want to write a key logger programm which transparently greps characters from stdin pass them to telnet /ssh and check the input strings for a given list of forbidden input...

Here is a littel starter

int i;

while (1){
i = getc(stdin);


My problem is that stdin per default is buffered and it waits till it receives <enter> from the user.

I used


do close stdin and reopen it as a new stream which is unbuffered but with no success
-> stdin still waits until it receives enter from the user....

So i did a little research and found that behaviour and settings of stdin is system dependent and i need to change it on linux using ioctl

I tried:

int n;
struct termios oldT, newT;
char c;

ioctl(0,TCGETS,&oldT); //get current mode

newT.c_lflag &= ~ECHO; // echo off
newT.c_lflag &= ~ICANON; //one char @ a time

ioctl(0,TCSETS,&newT); // set new terminal mode

read(0,&c,1); //read 1 char @ a time from stdin


but with no success... ...the option ICANON according to a google usenet entrie should do the job but didn't

I am running a debian system with kernel 2.4.21 and openwall patch

Any Suggestions?




Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Kaffeine always Buffering AvatarofVirgo Linux - General 1 10-13-2005 04:46 AM
pipeline buffering jk3us Linux - Software 2 12-17-2004 07:52 PM
turn off buffering suchi_s Programming 2 10-30-2004 07:14 AM
Streams and buffering problem MadCactus Programming 2 02-17-2004 01:32 PM
Regarding buffering with streams karthikvina Programming 0 09-04-2003 02:48 AM > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 06:19 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration