Results 1 to 10 of 10
I have a command running like:
Code:
tail -f logfile.txt
That's the difference between using
ctrl+c or
ctrl+z or
ctrl+d
ctrl+c seems like will terminate the program.
but with ctrl+z ...
- 04-14-2008 #1
[SOLVED] Difference bw ctrl C & ctrl D & ctrl Z
I have a command running like:
That's the difference between usingCode:tail -f logfile.txt
ctrl+c or
ctrl+z or
ctrl+d
ctrl+c seems like will terminate the program.
but with ctrl+z is suspended ?
what's this ctrl+d will do ?- Lakshmipathi.G
-------------------
FOSS India Award winning ext3fs Undelete tool and tutorials www.giis.co.in
First they criticize you,Then they laugh at you,Then they fight with you,Then you win. - M.K.Gandhi
-------------------
- 04-14-2008 #2
control d
You can use control d for EOF(end of file)
- 04-14-2008 #3
Thanks gerard4143

So finally
Ctrl + C To terminate
Ctrl + D signals EOF
Ctrl + Z suppends a program
HTH someone.
- Lakshmipathi.G
-------------------
FOSS India Award winning ext3fs Undelete tool and tutorials www.giis.co.in
First they criticize you,Then they laugh at you,Then they fight with you,Then you win. - M.K.Gandhi
-------------------
- 04-14-2008 #4
Just to clarify a bit: what Ctrl-C actually does is send a SIGQUIT signal to the process. A process is able to intercept this signal and do whatever it likes: for instance, from your Bash prompt, try hitting Ctrl-C. In Bash, it just cancels whatever you've typed and gives you a blank prompt (as opposed to quitting Bash).
DISTRO=Arch
Registered Linux User #388732
- 04-15-2008 #5
too much information
Here it goes: I'm posting too much information, I'm sure.
Actually, the signal usually associated with the ^C character is not SIGQUIT, but SIGINT.[W]hat Ctrl-C actually does is send a SIGQUIT signal to the process.
With that slight modification, what Cabhan says is true in normal circumstances. And this is definitely true:
But there are more ways in which a running program can do whatever it likes.A process is able to intercept this signal and do whatever it likes
First, it can associate with each of certain signals any ASCII character it likes. In addition, it is customary to specify the character hex FF to mean "Don't let any key on the keyboard cause this signal to be sent." Then your program doesn't have to go out of its way to explicitly ignore that signal or catch it.
Here are some signals, and the characters usually associated with them (which are overridable by the running program):
As Cabhan says, for each of these signals, a running program can either accept the default action, ignore the signal, or specify some other action written in the program's code.Code:SIGINT ^C (default action: terminate the process) SIGQUIT ^\ (default action: terminate the process and dump to a core file) SIGSUSP ^Z (default action: suspend the process)
Beyond signals, the running program can also specify which character (if any) is the end of file character. The default character for this, as gerard4143 and Lakshmipathi say, is ^D.
The interested C programmer would do well to type this at the shell prompt:
Code:man tcsetattr
--
Bill
Old age and treachery will overcome youth and skill.
- 04-15-2008 #6
Right, so I thought it was SIGINT, but I wasn't sure, and I checked signal(7), and saw SIGQUIT as "Interrupt from keyboard".
I have now rechecked that, and have seen that I was reading the wrong line <_<;.DISTRO=Arch
Registered Linux User #388732
- 04-15-2008 #7That's ok. I never make mistakes. (cough cough CHOKE)I was reading the wrong line--
Bill
Old age and treachery will overcome youth and skill.
- 04-15-2008 #8
Thanks guyz - For providing more insight to this topic
- Lakshmipathi.G
-------------------
FOSS India Award winning ext3fs Undelete tool and tutorials www.giis.co.in
First they criticize you,Then they laugh at you,Then they fight with you,Then you win. - M.K.Gandhi
-------------------
- 04-15-2008 #9Linux Engineer
- Join Date
- Apr 2006
- Location
- Saint Paul, MN, USA / CentOS, Debian, Solaris, SuSE
- Posts
- 1,117
Hi.
I like the way Stevens wrote in these topics:
If you are interested enough to explore farther, see the book below ... cheers, drlThe handling of terminal I/O is a messy area, regardless of the operating system. (Terminal I/O, Chapter 11)
Signals are software interrupts.
(Signals, Chapter 10)
Code:Title: Advanced Programming in the UNIX(R) Environment Author: W. Richard Stevens Edition: 1st Date: 1992 Publisher: Addison-Wesley Professional ISBN: 0-201-56317-7 Pages: 768 Categories: unix, system calls, programming, coding Comments: 4.5 stars at Amazon; there is a second edition 2005
Welcome - get the most out of the forum by reading forum basics and guidelines: click here.
90% of questions can be answered by using man pages, Quick Search, Advanced Search, Google search, Wikipedia.
We look forward to helping you with the challenge of the other 10%.
( Mn, 2.6.n, AMD-64 3000+, ASUS A8V Deluxe, 1 GB, SATA + IDE, Matrox G400 AGP )
- 04-15-2008 #10
Yes!
I agree. Advanced Programming in the UNIX Environment rocks, as do W. Richard Stevens's books on network programming.
--
Bill
Old age and treachery will overcome youth and skill.


