LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 08-30-2006, 11:40 PM   #1
maolibuduan
LQ Newbie
 
Registered: Aug 2006
Posts: 2

Rep: Reputation: 0
problem about tcflow


I wrote a proram which call tcflow(fd,TCOOFF) to suspend output and then call tcflow(fd, TCOON) to restore output in LINUX. fd is stdout's fd. the program suspended and I can't do any thing at the terminal to make it active. By gdb,I find process is suspending at tcflow(fd,TCOOFF).
What is the reason and how solve it?
Thanks for help.

#include <termios.h>
#include <unistd.h>
#include <stdlib.h>
char buf[]="Hello!";
int a[]={1,2,3,4,5,6,7,8,9,0};
int main()
{
int fd;
fd=fileno(stdout);
write(fd,buf,sizeof(buf));
tctrain(fd);
tcflow(fd, TCOOFF);/* process stop at here */
write(fd, a, 10);
tcflush(fd,TCIOFLUSH);
tcflow(fd,TCOON);
}

Last edited by maolibuduan; 08-31-2006 at 12:07 AM.
 
Old 08-31-2006, 01:07 AM   #2
xhi
Senior Member
 
Registered: Mar 2005
Location: USA::Pennsylvania
Distribution: Slackware
Posts: 1,065

Rep: Reputation: 45
it only seems to lock up when it is written to while it is disabled. is this you intention to write while it is off?
 
Old 08-31-2006, 05:43 AM   #3
maolibuduan
LQ Newbie
 
Registered: Aug 2006
Posts: 2

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by xhi
it only seems to lock up when it is written to while it is disabled. is this you intention to write while it is off?
thanks you help.
I just want to see what will happen while is off. Now I see WRITE will suspend process while transmission is disabled. This situation makes terminal unable working.

And there is another question about the code below:

#include <stdio.h>
#include <unistd.h>
#include <termios.h>
int main(void)
{
int fd;
fd = fileno(stdout);
write (fd,"Example of line control functions \n",34);
tcdrain (fd);
fprintf (stdout, "this line is delayed "); /* ??? */
tcflow(fd, TCOOFF);
tcflush(fd, TCIOFLUSH);
tcflow (fd, TCOON);
write(fd,"restart the output\n",20);
}

I run the program in LINUX and get result as below:

$a.out
Example of line control functions restart the output
this line is delayed $

It seems that the line outputed by fprintf should be
flushed by tcflush(), but it is not. why?

Maybe I am not well understand the mean of tcflush or the way of terminal i/o.
 
  


Reply



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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
perl problem? apache problem? cgi problem? WorldBuilder Linux - Software 1 09-17-2003 07:45 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 01:46 AM.

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