Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!


Click here to return to the 'Control+T in Terminal shows time snapshot' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Control+T in Terminal shows time snapshot
Authored by: arcticmac on Jan 27, '12 07:59:31AM

Yup. Or, for a program that will run long enough to get in a good test, any GUI program will work, since it runs until you quit it from the GUI.

I couldn't resist trying the rest of them to see if there were any other gems I didn't know about. There are all the usuals: Control-M and Control-J create a CR or LF (nominally respectively, though I'm not sure what the practical difference is here). Control-C sends a kill signal to the current process (not a hard kill though). Control-V followed by another letter lets you type other control characters in.

The most interesting one I found though was Control-Z, which (at least for the GUI app that I was trying) sent it a SIGSTOP and detached it from the terminal. SIGSTOP causes most programs to suspend and stop using CPU cycles (resume them with a SIGCONT), and detaching from the terminal is like running followed by an & - the command will still print any output to the terminal, but you have the shell back to do other things while you wait for it to be done.

I was curious if these (control-z, control-t) are Mac OS specific, or typical of most Unix OSes, so I googled, and found this page which is rather informative:
http://web.mit.edu/gnu/doc/html/features_5.html

Edited on Jan 27, '12 08:03:49AM by arcticmac


[ Reply to This | # ]
Control+T in Terminal shows time snapshot
Authored by: tofergregg on Jan 27, '12 08:14:36AM

To resume a program you have stopped with ^Z, you have two options:

type "fg" (without the quotes) to reattach it to the terminal (fg stands for "foreground")
type "bg" ("background") to restart the app but still have your terminal



[ Reply to This | # ]
Control+T in Terminal shows time snapshot
Authored by: arcticmac on Jan 27, '12 08:41:07AM

or something like "killall -CONT processname"



[ Reply to This | # ]
Control+T in Terminal shows time snapshot
Authored by: pauljlucas on Jan 27, '12 10:59:34AM
Control-M and Control-J create a CR or LF (nominally respectively, though I'm not sure what the practical difference is here).
There is no difference. In ASCII, Control-M (also written ^M) is CR and Control-J (^J) is LF. For example, a pure Unix terminal program can't tell the difference between you typing ^M vs return.
Control-V followed by another letter lets you type other control characters in.
That's more to do with the command-line editor you're currently using than the shell, i.e., that's what you type in vi.
---
- Paul


[ Reply to This | # ]
Control+T in Terminal shows time snapshot
Authored by: fido on Jan 28, '12 07:46:13AM
Any Unix program can see the CR's and LF's separately if the programmer chooses. They just have to turn off icrnl or put the tty into raw mode. To say that there is no difference between the two is a little misleading.

Example:

#!/bin/sh
stty -icrnl
echo "Type something, hit control M or enter/return a few times, then hit control J"
read ans
echo "You typed:"
echo $ans | od -a
stty icrnl
Also, control V is the usual setting for the tty's "literal next" (lnext) setting and is not limited to command line editors. Try running a simple command like sleep 30, then hit ^V^M and ^V^J to see that there is a difference between the two.

In Terminal the key labelled "return" will produce the same results as hitting ^M because they're both ways to generate a carriage return (CR). If icrnl is on (see stty -e) then these will be mapped to newlines.

[ Reply to This | # ]

Control+T in Terminal shows time snapshot
Authored by: wallybear on Jan 30, '12 02:11:39PM

"detaching from the terminal is like running followed by an & "

No, it isn't.

Ctrl-Z suspends the process. If you want it to continue in background (like when you use &) you must type
"bg" (=background) on the command line, otherwise typing "fg" it will resume in foreground.
It's useful when you launch a process you want to run in background and you forget to put the "&" at the end of the command: just do Ctrl-Z, type "bg" and you are done.

It's a common feature of Linuxes and BSD.



[ Reply to This | # ]