summaryrefslogtreecommitdiff
path: root/st.c
diff options
context:
space:
mode:
authorRoberto E. Vargas Caballero <k0ga@shike2.com>2012-09-12 21:51:55 +0200
committerRoberto E. Vargas Caballero <k0ga@shike2.com>2012-09-12 21:51:55 +0200
commit720cb816dcff55f8b75bdc2a8ffa265f460f5d55 (patch)
tree1e399c343f102eca23f2cbe97c2d33414b42bb93 /st.c
parentb9d5fec4f277b688b3bb4741134abf152e801e90 (diff)
Remove buffering to fileio instead of calling fflush
By default text files are line buffered, and this means that -f option will not write the line until a \n is printed. This is not very useful for debugging, so a call to fflush was added. This patch substitute this call (which will be done by each character painted) by the full remove of the buffering in the file. --- st.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-)
Diffstat (limited to 'st.c')
-rw-r--r--st.c12
1 files changed, 5 insertions, 7 deletions
diff --git a/st.c b/st.c
index 8741145..19d0a86 100644
--- a/st.c
+++ b/st.c
@@ -355,7 +355,7 @@ static STREscape strescseq;
static int cmdfd;
static pid_t pid;
static Selection sel;
-static FILE *fileio;
+static int iofd = -1;
static char **opt_cmd = NULL;
static char *opt_io = NULL;
static char *opt_title = NULL;
@@ -821,9 +821,9 @@ ttynew(void) {
signal(SIGCHLD, sigchld);
if(opt_io) {
if(!strcmp(opt_io, "-")) {
- fileio = stdout;
+ iofd = STDOUT_FILENO;
} else {
- if(!(fileio = fopen(opt_io, "w"))) {
+ if((iofd = open(opt_io, O_WRONLY | O_CREAT, 0666)) < 0) {
fprintf(stderr, "Error opening %s:%s\n",
opt_io, strerror(errno));
}
@@ -1599,10 +1599,8 @@ void
tputc(char *c) {
char ascii = *c;
- if(fileio) {
- putc(ascii, fileio);
- fflush(fileio);
- }
+ if(iofd != -1)
+ write(iofd, c, 1);
if(term.esc & ESC_START) {
if(term.esc & ESC_CSI) {