mirror of
https://github.com/openbsd/src.git
synced 2025-01-03 06:45:37 -08:00
Prefer setvbuf() to setlinebuf() for portability; ok deraadt@
This commit is contained in:
parent
28c10ccf16
commit
b9a887b60d
@ -1,4 +1,4 @@
|
||||
/* $OpenBSD: main.c,v 1.40 2014/07/12 02:47:51 guenther Exp $ */
|
||||
/* $OpenBSD: main.c,v 1.41 2014/11/26 18:34:51 millert Exp $ */
|
||||
/* $NetBSD: main.c,v 1.3 1995/03/21 09:04:44 cgd Exp $ */
|
||||
|
||||
/* main.c: This file contains the main control and user-interface routines
|
||||
@ -141,7 +141,7 @@ top:
|
||||
if (fstat(STDIN_FILENO, &sb) || !S_ISFIFO(sb.st_mode)) {
|
||||
if (lseek(STDIN_FILENO, 0, SEEK_CUR)) {
|
||||
interactive = 1;
|
||||
setlinebuf(stdout);
|
||||
setvbuf(stdout, NULL, _IOLBF, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $OpenBSD: cradle.c,v 1.7 2014/10/25 03:17:45 lteo Exp $ */
|
||||
/* $OpenBSD: cradle.c,v 1.8 2014/11/26 18:34:51 millert Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2003 Marius Aamodt Eriksen <marius@monkey.org>
|
||||
@ -241,7 +241,7 @@ cradle_start(char *path, char *uipath, char *guipath)
|
||||
err(1, "dup2");
|
||||
if (dup2(s, fileno(stdout)) == -1)
|
||||
err(1, "dup2");
|
||||
setlinebuf(stdout);
|
||||
setvbuf(stdout, NULL, _IOLBF, 0);
|
||||
|
||||
connected = 1;
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $OpenBSD: systrace.c,v 1.60 2014/08/25 07:50:25 doug Exp $ */
|
||||
/* $OpenBSD: systrace.c,v 1.61 2014/11/26 18:34:51 millert Exp $ */
|
||||
/*
|
||||
* Copyright 2002 Niels Provos <provos@citi.umich.edu>
|
||||
* All rights reserved.
|
||||
@ -503,7 +503,7 @@ requestor_start(char *path, int docradle)
|
||||
err(1, "dup2");
|
||||
if (dup2(pair[1], fileno(stdout)) == -1)
|
||||
err(1, "dup2");
|
||||
setlinebuf(stdout);
|
||||
setvbuf(stdout, NULL, _IOLBF, 0);
|
||||
|
||||
close(pair[1]);
|
||||
}
|
||||
@ -524,7 +524,7 @@ requestor_start(char *path, int docradle)
|
||||
|
||||
close(pair[0]);
|
||||
|
||||
setlinebuf(stdout);
|
||||
setvbuf(stdout, NULL, _IOLBF, 0);
|
||||
|
||||
connected = 1;
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $OpenBSD: main.c,v 1.20 2013/11/15 22:20:04 millert Exp $ */
|
||||
/* $OpenBSD: main.c,v 1.21 2014/11/26 18:34:51 millert Exp $ */
|
||||
/* $NetBSD: main.c,v 1.13 1997/07/01 05:37:51 lukem Exp $ */
|
||||
|
||||
/*
|
||||
@ -157,7 +157,7 @@ main(int argc, char *argv[])
|
||||
(void)signal(SIGINT, SIG_IGN);
|
||||
if (signal(SIGTERM, onintr) == SIG_IGN)
|
||||
(void)signal(SIGTERM, SIG_IGN);
|
||||
setlinebuf(stderr);
|
||||
setvbuf(stderr, NULL, _IOLBF, 0);
|
||||
|
||||
atexit(cleanup);
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
%{
|
||||
/* $OpenBSD: bc.y,v 1.46 2014/10/14 15:35:18 deraadt Exp $ */
|
||||
/* $OpenBSD: bc.y,v 1.47 2014/11/26 18:34:51 millert Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2003, Otto Moerbeek <otto@drijf.net>
|
||||
@ -1095,7 +1095,7 @@ main(int argc, char *argv[])
|
||||
char *q;
|
||||
|
||||
init();
|
||||
setlinebuf(stdout);
|
||||
setvbuf(stdout, NULL, _IOLBF, 0);
|
||||
|
||||
sargv = reallocarray(NULL, argc, sizeof(char *));
|
||||
if (sargv == NULL)
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $OpenBSD: dc.c,v 1.12 2014/05/20 01:25:23 guenther Exp $ */
|
||||
/* $OpenBSD: dc.c,v 1.13 2014/11/26 18:34:51 millert Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2003, Otto Moerbeek <otto@drijf.net>
|
||||
@ -72,8 +72,8 @@ main(int argc, char *argv[])
|
||||
argv += optind;
|
||||
|
||||
init_bmachine(extended_regs);
|
||||
(void)setlinebuf(stdout);
|
||||
(void)setlinebuf(stderr);
|
||||
(void)setvbuf(stdout, NULL, _IOLBF, 0);
|
||||
(void)setvbuf(stderr, NULL, _IOLBF, 0);
|
||||
|
||||
if (argc > 1)
|
||||
usage();
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $OpenBSD: gprof.c,v 1.19 2009/10/27 23:59:38 deraadt Exp $ */
|
||||
/* $OpenBSD: gprof.c,v 1.20 2014/11/26 18:34:51 millert Exp $ */
|
||||
/* $NetBSD: gprof.c,v 1.8 1995/04/19 07:15:59 cgd Exp $ */
|
||||
|
||||
/*
|
||||
@ -72,7 +72,7 @@ main(int argc, char *argv[])
|
||||
break;
|
||||
case 'd':
|
||||
dflag = TRUE;
|
||||
setlinebuf(stdout);
|
||||
setvbuf(stdout, NULL, _IOLBF, 0);
|
||||
debug |= atoi( *++argv );
|
||||
debug |= ANYDEBUG;
|
||||
# ifdef DEBUG
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $OpenBSD: grep.c,v 1.46 2014/11/26 17:26:40 millert Exp $ */
|
||||
/* $OpenBSD: grep.c,v 1.47 2014/11/26 18:34:51 millert Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1999 James Howard and Dag-Erling Coïdan Smørgrav
|
||||
@ -484,7 +484,7 @@ main(int argc, char *argv[])
|
||||
}
|
||||
|
||||
if (lbflag)
|
||||
setlinebuf(stdout);
|
||||
setvbuf(stdout, NULL, _IOLBF, 0);
|
||||
|
||||
if ((argc == 0 || argc == 1) && !Rflag && !Hflag)
|
||||
hflag = 1;
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $OpenBSD: last.c,v 1.42 2014/04/22 12:36:36 okan Exp $ */
|
||||
/* $OpenBSD: last.c,v 1.43 2014/11/26 18:34:51 millert Exp $ */
|
||||
/* $NetBSD: last.c,v 1.6 1994/12/24 16:49:02 cgd Exp $ */
|
||||
|
||||
/*
|
||||
@ -152,7 +152,7 @@ main(int argc, char *argv[])
|
||||
exit(0);
|
||||
|
||||
if (argc) {
|
||||
setlinebuf(stdout);
|
||||
setvbuf(stdout, NULL, _IOLBF, 0);
|
||||
for (argv += optind; *argv; ++argv) {
|
||||
#define COMPATIBILITY
|
||||
#ifdef COMPATIBILITY
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $OpenBSD: leave.c,v 1.13 2013/11/26 13:19:07 deraadt Exp $ */
|
||||
/* $OpenBSD: leave.c,v 1.14 2014/11/26 18:34:51 millert Exp $ */
|
||||
/* $NetBSD: leave.c,v 1.4 1995/07/03 16:50:13 phil Exp $ */
|
||||
|
||||
/*
|
||||
@ -64,7 +64,7 @@ main(int argc, char *argv[])
|
||||
int plusnow = 0, twentyfour;
|
||||
char buf[50];
|
||||
|
||||
if (setlinebuf(stdout) != 0)
|
||||
if (setvbuf(stdout, NULL, _IOLBF, 0) != 0)
|
||||
errx(1, "Cannot set stdout to line buffered.");
|
||||
|
||||
if (argc < 2) {
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $OpenBSD: patch.c,v 1.51 2013/11/26 13:19:07 deraadt Exp $ */
|
||||
/* $OpenBSD: patch.c,v 1.52 2014/11/26 18:34:51 millert Exp $ */
|
||||
|
||||
/*
|
||||
* patch - a program to apply diffs to original files
|
||||
@ -147,8 +147,8 @@ main(int argc, char *argv[])
|
||||
const char *tmpdir;
|
||||
char *v;
|
||||
|
||||
setlinebuf(stdout);
|
||||
setlinebuf(stderr);
|
||||
setvbuf(stdout, NULL, _IOLBF, 0);
|
||||
setvbuf(stderr, NULL, _IOLBF, 0);
|
||||
for (i = 0; i < MAXFILEC; i++)
|
||||
filearg[i] = NULL;
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $OpenBSD: rup.c,v 1.27 2014/10/08 04:08:13 doug Exp $ */
|
||||
/* $OpenBSD: rup.c,v 1.28 2014/11/26 18:34:51 millert Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1993, John Brezak
|
||||
@ -314,7 +314,7 @@ main(int argc, char *argv[])
|
||||
/*NOTREACHED*/
|
||||
}
|
||||
|
||||
setlinebuf(stdout);
|
||||
setvbuf(stdout, NULL, _IOLBF, 0);
|
||||
|
||||
if (argc == optind)
|
||||
allhosts();
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $OpenBSD: rusers.c,v 1.32 2014/10/08 04:08:47 doug Exp $ */
|
||||
/* $OpenBSD: rusers.c,v 1.33 2014/11/26 18:34:51 millert Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2001, 2003 Todd C. Miller <Todd.Miller@courtesan.com>
|
||||
@ -152,7 +152,7 @@ main(int argc, char **argv)
|
||||
termwidth = 80;
|
||||
} else
|
||||
termwidth = 80;
|
||||
setlinebuf(stdout);
|
||||
setvbuf(stdout, NULL, _IOLBF, 0);
|
||||
|
||||
if (argc == optind) {
|
||||
if (hflag || iflag || uflag) {
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $OpenBSD: main.c,v 1.17 2009/10/27 23:59:43 deraadt Exp $ */
|
||||
/* $OpenBSD: main.c,v 1.18 2014/11/26 18:34:51 millert Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1992 Diomidis Spinellis.
|
||||
@ -118,7 +118,7 @@ main(int argc, char *argv[])
|
||||
nflag = 1;
|
||||
break;
|
||||
case 'u':
|
||||
setlinebuf(stdout);
|
||||
setvbuf(stdout, NULL, _IOLBF, 0);
|
||||
break;
|
||||
default:
|
||||
case '?':
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $OpenBSD: sftp.c,v 1.167 2014/10/06 00:47:15 djm Exp $ */
|
||||
/* $OpenBSD: sftp.c,v 1.168 2014/11/26 18:34:51 millert Exp $ */
|
||||
/*
|
||||
* Copyright (c) 2001-2004 Damien Miller <djm@openbsd.org>
|
||||
*
|
||||
@ -2059,8 +2059,8 @@ interactive_loop(struct sftp_conn *conn, char *file1, char *file2)
|
||||
free(dir);
|
||||
}
|
||||
|
||||
setlinebuf(stdout);
|
||||
setlinebuf(infile);
|
||||
setvbuf(stdout, NULL, _IOLBF, 0);
|
||||
setvbuf(infile, NULL, _IOLBF, 0);
|
||||
|
||||
interactive = !batchmode && isatty(STDIN_FILENO);
|
||||
err = 0;
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $OpenBSD: ssh-add.c,v 1.113 2014/07/09 14:15:56 benno Exp $ */
|
||||
/* $OpenBSD: ssh-add.c,v 1.114 2014/11/26 18:34:51 millert Exp $ */
|
||||
/*
|
||||
* Author: Tatu Ylonen <ylo@cs.hut.fi>
|
||||
* Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
|
||||
@ -428,7 +428,7 @@ main(int argc, char **argv)
|
||||
|
||||
OpenSSL_add_all_algorithms();
|
||||
|
||||
setlinebuf(stdout);
|
||||
setvbuf(stdout, NULL, _IOLBF, 0);
|
||||
|
||||
/* At first, get a connection to the authentication agent. */
|
||||
ac = ssh_get_authentication_connection();
|
||||
|
@ -1003,7 +1003,7 @@ main(int argc, char **argv)
|
||||
struct statctx *udp_sc = NULL;
|
||||
|
||||
/* Init world */
|
||||
setlinebuf(stdout);
|
||||
setvbuf(stdout, NULL, _IOLBF, 0);
|
||||
ptb = &tcpbench;
|
||||
ptb->dummybuf_len = 0;
|
||||
ptb->Sflag = ptb->sflag = ptb->vflag = 0;
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $OpenBSD: log.c,v 1.11 2014/10/20 23:57:13 nicm Exp $ */
|
||||
/* $OpenBSD: log.c,v 1.12 2014/11/26 18:34:51 millert Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||
@ -45,7 +45,7 @@ log_open(const char *path)
|
||||
if (log_file == NULL)
|
||||
return;
|
||||
|
||||
setlinebuf(log_file);
|
||||
setvbuf(log_file, NULL, _IOLBF, 0);
|
||||
event_set_log_callback(log_event_cb);
|
||||
|
||||
tzset();
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $OpenBSD: cron.c,v 1.45 2014/10/29 04:39:02 deraadt Exp $ */
|
||||
/* $OpenBSD: cron.c,v 1.46 2014/11/26 18:34:52 millert Exp $ */
|
||||
|
||||
/* Copyright 1988,1990,1993,1994 by Paul Vixie
|
||||
* All rights reserved
|
||||
@ -72,10 +72,8 @@ main(int argc, char *argv[]) {
|
||||
|
||||
setlocale(LC_ALL, "");
|
||||
|
||||
#if defined(BSD)
|
||||
setlinebuf(stdout);
|
||||
setlinebuf(stderr);
|
||||
#endif
|
||||
setvbuf(stdout, NULL, _IOLBF, 0);
|
||||
setvbuf(stderr, NULL, _IOLBF, 0);
|
||||
|
||||
NoFork = 0;
|
||||
parse_args(argc, argv);
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $OpenBSD: crontab.c,v 1.64 2011/08/22 19:32:42 millert Exp $ */
|
||||
/* $OpenBSD: crontab.c,v 1.65 2014/11/26 18:34:52 millert Exp $ */
|
||||
|
||||
/* Copyright 1988,1990,1993,1994 by Paul Vixie
|
||||
* All rights reserved
|
||||
@ -82,9 +82,7 @@ main(int argc, char *argv[]) {
|
||||
|
||||
setlocale(LC_ALL, "");
|
||||
|
||||
#if defined(BSD)
|
||||
setlinebuf(stderr);
|
||||
#endif
|
||||
setvbuf(stderr, NULL, _IOLBF, 0);
|
||||
parse_args(argc, argv); /* sets many globals, opens a file */
|
||||
set_cron_cwd();
|
||||
if (!allowed(RealUser, CRON_ALLOW, CRON_DENY)) {
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $OpenBSD: mapper.c,v 1.20 2011/09/21 18:48:43 jsg Exp $ */
|
||||
/* $OpenBSD: mapper.c,v 1.21 2014/11/26 18:34:51 millert Exp $ */
|
||||
/* $NetBSD: mapper.c,v 1.3 1995/12/10 11:12:04 mycroft Exp $ */
|
||||
|
||||
/* Mapper for connections between MRouteD multicast routers.
|
||||
@ -810,7 +810,7 @@ int main(int argc, char *argv[])
|
||||
init_igmp();
|
||||
setuid(getuid());
|
||||
|
||||
setlinebuf(stderr);
|
||||
setvbuf(stderr, NULL, _IOLBF, 0);
|
||||
|
||||
while ((ch = getopt(argc, argv, "d::fgnr:t:")) != -1) {
|
||||
switch (ch) {
|
||||
|
@ -298,7 +298,7 @@ main(int argc, char *argv[])
|
||||
if (setresuid(uid, uid, uid) == -1)
|
||||
err(1, "setresuid");
|
||||
|
||||
setlinebuf(stderr);
|
||||
setvbuf(stderr, NULL, _IOLBF, 0);
|
||||
|
||||
while ((ch = getopt(argc, argv, "d::nr:t:")) != -1) {
|
||||
switch (ch) {
|
||||
|
@ -89,7 +89,6 @@ typedef void (*ihfunc_t)(int);
|
||||
#ifdef SYSV
|
||||
#define bcopy(a, b, c) memcpy(b, a, c)
|
||||
#define bzero(s, n) memset((s), 0, (n))
|
||||
#define setlinebuf(s) setvbuf(s, NULL, _IOLBF, 0)
|
||||
#define signal(s,f) sigset(s,f)
|
||||
#endif
|
||||
|
||||
|
@ -89,7 +89,7 @@ main(int argc, char *argv[])
|
||||
fprintf(stderr, "must be root\n");
|
||||
exit(1);
|
||||
}
|
||||
setlinebuf(stderr);
|
||||
setvbuf(stderr, NULL, _IOLBF, 0);
|
||||
|
||||
while ((ch = getopt(argc, argv, "c:d::p")) != -1) {
|
||||
switch (ch) {
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $OpenBSD: syslogc.c,v 1.16 2011/07/12 11:28:31 sthen Exp $ */
|
||||
/* $OpenBSD: syslogc.c,v 1.17 2014/11/26 18:34:52 millert Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2004 Damien Miller
|
||||
@ -154,8 +154,8 @@ main(int argc, char **argv)
|
||||
err(1, "fwrite");
|
||||
|
||||
fflush(ctlf);
|
||||
setlinebuf(ctlf);
|
||||
setlinebuf(stdout);
|
||||
setvbuf(ctlf, NULL, _IOLBF, 0);
|
||||
setvbuf(stdout, NULL, _IOLBF, 0);
|
||||
|
||||
/* Fetch header */
|
||||
if (fread(&rr, sizeof(rr), 1, ctlf) != 1)
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $OpenBSD: syslogd.c,v 1.130 2014/11/01 12:07:41 bluhm Exp $ */
|
||||
/* $OpenBSD: syslogd.c,v 1.131 2014/11/26 18:34:52 millert Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1983, 1988, 1993, 1994
|
||||
@ -347,7 +347,7 @@ main(int argc, char *argv[])
|
||||
usage();
|
||||
|
||||
if (Debug)
|
||||
setlinebuf(stdout);
|
||||
setvbuf(stdout, NULL, _IOLBF, 0);
|
||||
|
||||
if ((fd = nullfd = open(_PATH_DEVNULL, O_RDWR)) == -1) {
|
||||
logerror("Couldn't open /dev/null");
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $OpenBSD: tcpdump.c,v 1.66 2014/06/30 04:25:11 deraadt Exp $ */
|
||||
/* $OpenBSD: tcpdump.c,v 1.67 2014/11/26 18:34:52 millert Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997
|
||||
@ -277,11 +277,7 @@ main(int argc, char **argv)
|
||||
break;
|
||||
|
||||
case 'l':
|
||||
#ifdef HAVE_SETLINEBUF
|
||||
setlinebuf(stdout);
|
||||
#else
|
||||
setvbuf(stdout, NULL, _IOLBF, 0);
|
||||
#endif
|
||||
break;
|
||||
case 'L':
|
||||
++Lflag;
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $OpenBSD: trpt.c,v 1.28 2011/07/04 07:06:49 guenther Exp $ */
|
||||
/* $OpenBSD: trpt.c,v 1.29 2014/11/26 18:34:52 millert Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1997 The NetBSD Foundation, Inc.
|
||||
@ -140,7 +140,7 @@ main(int argc, char *argv[])
|
||||
break;
|
||||
case 'f':
|
||||
++follow;
|
||||
setlinebuf(stdout);
|
||||
setvbuf(stdout, NULL, _IOLBF, 0);
|
||||
break;
|
||||
case 'j':
|
||||
++jflag;
|
||||
|
Loading…
Reference in New Issue
Block a user