Add *fshut() functions to properly flush file streams

This has been a known issue for a long time. Example:

printf "word" > /dev/full

wouldn't report there's not enough space on the device.
This is due to the fact that every libc has internal buffers
for stdout which store fragments of written data until they reach
a certain size or on some callback to flush them all at once to the
kernel.
You can force the libc to flush them with fflush(). In case flushing
fails, you can check the return value of fflush() and report an error.

However, previously, sbase didn't have such checks and without fflush(),
the libc silently flushes the buffers on exit without checking the errors.
No offense, but there's no way for the libc to report errors in the exit-
condition.

GNU coreutils solve this by having onexit-callbacks to handle the flushing
and report issues, but they have obvious deficiencies.
After long discussions on IRC, we came to the conclusion that checking the
return value of every io-function would be a bit too much, and having a
general-purpose fclose-wrapper would be the best way to go.

It turned out that fclose() alone is not enough to detect errors. The right
way to do it is to fflush() + check ferror on the fp and then to a fclose().
This is what fshut does and that's how it's done before each return.
The return value is obviously affected, reporting an error in case a flush
or close failed, but also when reading failed for some reason, the error-
state is caught.

the !!( ... + ...) construction is used to call all functions inside the
brackets and not "terminating" on the first.
We want errors to be reported, but there's no reason to stop flushing buffers
when one other file buffer has issues.
Obviously, functionales come before the flush and ret-logic comes after to
prevent early exits as well without reporting warnings if there are any.

One more advantage of fshut() is that it is even able to report errors
on obscure NFS-setups which the other coreutils are unable to detect,
because they only check the return-value of fflush() and fclose(),
not ferror() as well.
This commit is contained in:
FRIGN 2015-04-04 21:25:17 +02:00 committed by sin
parent 11d59a78c8
commit 11e2d472bf
60 changed files with 175 additions and 118 deletions

View File

@ -50,6 +50,7 @@ LIBUTILSRC =\
libutil/eregcomp.c\
libutil/estrtod.c\
libutil/fnck.c\
libutil/fshut.c\
libutil/getlines.c\
libutil/human.c\
libutil/md5.c\

View File

@ -33,5 +33,5 @@ main(int argc, char *argv[])
}
puts(p);
return 0;
return fshut(stdout, "<stdout>");
}

2
cal.c
View File

@ -208,5 +208,5 @@ main(int argc, char *argv[])
drawcal(year, month - 1, ncols, nmons, fday);
return 0;
return fshut(stdout, "<stdout>");
}

6
cat.c
View File

@ -36,10 +36,12 @@ main(int argc, char *argv[])
ret = 1;
} else {
concat(fp, *argv, stdout, "<stdout>");
fclose(fp);
if (fshut(fp, *argv)) {
ret = 1;
}
}
}
}
return ret;
return !!(fshut(stdin, "<stdin>") + fshut(stdout, "<stdout>")) || ret;
}

View File

@ -111,9 +111,11 @@ main(int argc, char *argv[])
continue;
}
cksum(fp, *argv);
fclose(fp);
if (fshut(fp, *argv)) {
ret = 1;
}
}
}
return ret;
return fshut(stdout, "<stdout>") || ret;
}

4
cmp.c
View File

@ -71,5 +71,9 @@ main(int argc, char *argv[])
}
}
enfshut(2, fp[0], argv[0]);
if (fp[0] != fp[1])
enfshut(2, fp[1], argv[1]);
enfshut(2, stdout, "<stdout>");
return !same;
}

2
col.c
View File

@ -217,5 +217,5 @@ main(int argc, char *argv[])
col();
flush();
return 0;
return !!(fshut(stdin, "<stdin>") + fshut(stdout, "<stdout>"));
}

8
cols.c
View File

@ -25,7 +25,7 @@ main(int argc, char *argv[])
struct winsize w;
struct linebuf b = EMPTY_LINEBUF;
size_t chars = 65, maxlen = 0, i, j, k, len, bytes, cols, rows;
int cflag = 0;
int cflag = 0, ret = 0;
char *p;
ARGBEGIN {
@ -50,10 +50,12 @@ main(int argc, char *argv[])
for (; *argv; argc--, argv++) {
if (!(fp = fopen(*argv, "r"))) {
weprintf("fopen %s:", *argv);
ret = 1;
continue;
}
getlines(fp, &b);
fclose(fp);
if (fshut(fp, *argv))
ret = 1;
}
}
@ -82,5 +84,5 @@ main(int argc, char *argv[])
putchar('\n');
}
return 0;
return !!(fshut(stdin, "<stdin>") + fshut(stdout, "<stdout>")) || ret;
}

5
comm.c
View File

@ -76,8 +76,9 @@ main(int argc, char *argv[])
}
diff = strcmp(line[0], line[1]);
LIMIT(diff, -1, 1);
printline((2-diff) % 3, line[MAX(0, diff)]);
printline((2 - diff) % 3, line[MAX(0, diff)]);
}
end:
return 0;
return !!(fshut(fp[0], argv[0]) + (fp[0] != fp[1] && fshut(fp[1], argv[1])) +
fshut(stdout, "<stdout>"));
}

View File

@ -11,6 +11,6 @@ AR = ar
RANLIB = ranlib
# For NetBSD add -D_NETBSD_SOURCE
CPPFLAGS = -D_DEFAULT_SOURCE -D_BSD_SOURCE -D_XOPEN_SOURCE=700
CPPFLAGS = -D_DEFAULT_SOURCE -D_BSD_SOURCE -D_XOPEN_SOURCE=700 -DDEBUG
CFLAGS = -std=c99 -Wall -pedantic
LDFLAGS = -s # -lrt

2
cp.c
View File

@ -53,5 +53,5 @@ main(int argc, char *argv[])
}
enmasse(argc, argv, cp);
return cp_status;
return fshut(stdout, "<stdout>") || cp_status;
}

5
cut.c
View File

@ -196,10 +196,11 @@ main(int argc, char *argv[])
continue;
}
cut(fp, *argv);
fclose(fp);
if (fshut(fp, *argv))
ret = 1;
}
}
}
return ret;
return !!(fshut(stdin, "<stdin>") + fshut(stdout, "<stdout>")) || ret;
}

2
date.c
View File

@ -45,5 +45,5 @@ main(int argc, char *argv[])
strftime(buf, sizeof(buf), fmt, now);
puts(buf);
return 0;
return fshut(stdout, "<stdout>");
}

View File

@ -23,5 +23,5 @@ main(int argc, char *argv[])
puts(dirname(argv[0]));
return 0;
return fshut(stdout, "<stdout>");
}

2
du.c
View File

@ -108,5 +108,5 @@ main(int argc, char *argv[])
}
}
return recurse_status;
return fshut(stdout, "<stdout>") || recurse_status;
}

2
echo.c
View File

@ -18,5 +18,5 @@ main(int argc, char *argv[])
if (!nflag)
putchar('\n');
return 0;
return fshut(stdout, "<stdout>");
}

2
env.c
View File

@ -45,5 +45,5 @@ main(int argc, char *argv[])
for (; environ && *environ; environ++)
puts(*environ);
return 0;
return fshut(stdout, "<stdout>");
}

View File

@ -116,9 +116,10 @@ main(int argc, char *argv[])
continue;
}
expand(*argv, fp);
fclose(fp);
if (fshut(fp, *argv))
ret = 1;
}
}
return ret;
return !!(fshut(stdin, "<stdin>") + fshut(stdout, "<stdout>")) || ret;
}

1
expr.c
View File

@ -266,5 +266,6 @@ main(int argc, char *argv[])
usage();
} ARGEND;
enfshut(3, stdout, "<stdout>");
return !parse(argv, argc);
}

2
find.c
View File

@ -1036,5 +1036,5 @@ main(int argc, char **argv)
t->u.pinfo->freearg(t->extra);
free(toks);
return gflags.ret;
return !!(fshut(stdin, "<stdin>") + fshut(stdout, "<stdout>")) || gflags.ret;
}

5
fold.c
View File

@ -100,10 +100,11 @@ main(int argc, char *argv[])
ret = 1;
} else {
fold(fp, *argv);
fclose(fp);
if (fshut(fp, *argv))
ret = 1;
}
}
}
return ret;
return !!(fshut(stdin, "<stdin>") + fshut(stdout, "<stdout>")) || ret;
}

12
grep.c
View File

@ -196,7 +196,7 @@ main(int argc, char *argv[])
if (!(fp = fmemopen(arg, strlen(arg) + 1, "r")))
eprintf("fmemopen:");
addpatternfile(fp);
fclose(fp);
efshut(fp, arg);
eflag = 1;
break;
case 'f':
@ -205,7 +205,7 @@ main(int argc, char *argv[])
if (!fp)
enprintf(Error, "fopen %s:", arg);
addpatternfile(fp);
fclose(fp);
efshut(fp, arg);
fflag = 1;
break;
case 'h':
@ -246,7 +246,7 @@ main(int argc, char *argv[])
if (!(fp = fmemopen(argv[0], strlen(argv[0]) + 1, "r")))
eprintf("fmemopen:");
addpatternfile(fp);
fclose(fp);
efshut(fp, argv[0]);
argc--;
argv++;
}
@ -269,8 +269,12 @@ main(int argc, char *argv[])
m = grep(fp, argv[i]);
if (m == Error || (match != Error && m == Match))
match = m;
fclose(fp);
if (fshut(fp, argv[i]))
match = Error;
}
}
enfshut(Error, stdin, "<stdin>");
enfshut(Error, stdout, "<stdout>");
return match;
}

5
head.c
View File

@ -62,9 +62,10 @@ main(int argc, char *argv[])
}
newline = 1;
head(fp, *argv, n);
fclose(fp);
if(fshut(fp, *argv))
ret = 1;
}
}
return ret;
return !!(fshut(stdin, "<stdin>") + fshut(stdout, "<stdout>")) || ret;
}

View File

@ -32,5 +32,5 @@ main(int argc, char *argv[])
usage();
}
return 0;
return fshut(stdout, "<stdout>");
}

4
kill.c
View File

@ -74,17 +74,15 @@ main(int argc, char *argv[])
if (!argc) {
for (i = 0; i < LEN(sigs); i++)
puts(sigs[i].name);
return 0;
} else if (argc == 1) {
sig = estrtonum(*argv, 0, INT_MAX);
if (sig > 128)
sig = WTERMSIG(sig);
puts(sig2name(sig));
return 0;
} else {
usage();
}
break;
return fshut(stdout, "<stdout>");
case 's':
if ((*argv)[2])
goto longopt;

View File

@ -12,11 +12,8 @@ concat(FILE *fp1, const char *s1, FILE *fp2, const char *s2)
while ((n = fread(buf, 1, sizeof(buf), fp1))) {
fwrite(buf, 1, n, fp2);
if (ferror(fp2))
eprintf("fwrite %s:", s2);
if (feof(fp1) || ferror(fp1))
if (feof(fp1) || ferror(fp1) || ferror(fp2))
break;
}
if (ferror(fp1))
eprintf("fread %s", s1);
}

37
libutil/fshut.c Normal file
View File

@ -0,0 +1,37 @@
#include <stdio.h>
#include <stdlib.h>
#include "../util.h"
int fshut(FILE *fp, const char *fname)
{
int ret = 0;
if (fflush(fp) && !ret) {
weprintf("fflush %s:", fname);
ret = 1;
}
if (ferror(fp) && !ret) {
weprintf("ferror %s:", fname);
ret = 1;
}
if (fclose(fp) && !ret) {
weprintf("fclose %s:", fname);
ret = 1;
}
return ret;
}
void enfshut(int status, FILE *fp, const char *fname)
{
if (fshut(fp, fname))
exit(status);
}
void efshut(FILE *fp, const char *fname)
{
enfshut(1, fp, fname);
}

View File

@ -72,8 +72,6 @@ main(int argc, char *argv[])
if (!argc) {
while (getline(&buf, &sz, stdin) > 0)
syslog(priority, "%s", buf);
if (ferror(stdin))
eprintf("getline %s:", "<stdin>");
} else {
for (i = 0, sz = 0; i < argc; i++)
sz += strlen(argv[i]);
@ -89,5 +87,5 @@ main(int argc, char *argv[])
closelog();
return 0;
return fshut(stdin, "<stdin>");
}

View File

@ -25,5 +25,5 @@ main(int argc, char *argv[])
else
eprintf("no login name\n");
return 0;
return fshut(stdout, "<stdout>");
}

2
ls.c
View File

@ -365,5 +365,5 @@ main(int argc, char *argv[])
for (i = 0; i < argc; i++)
ls(&ents[rflag ? argc-i-1 : i], 1);
return 0;
return fshut(stdout, "<stdout>");
}

View File

@ -35,5 +35,6 @@ main(int argc, char *argv[])
usage();
} ARGEND;
return cryptfunc(argc, argv, &md5_ops, md, sizeof(md));
return cryptfunc(argc, argv, &md5_ops, md, sizeof(md)) ||
!!(fshut(stdin, "<stdin>") + fshut(stdout, "<stdout>"));
}

View File

@ -61,9 +61,11 @@ main(int argc, char *argv[])
eprintf("mkstemp %s:", path);
return 1;
}
close(fd);
if (close(fd))
eprintf("close %s:", path);
}
puts(path);
efshut(stdout, "<stdout>");
return 0;
}

4
nl.c
View File

@ -193,8 +193,8 @@ main(int argc, char *argv[])
if (!(fp = fopen(argv[0], "r")))
eprintf("fopen %s:", argv[0]);
nl(argv[0], fp);
fclose(fp);
}
return 0;
return !!(fshut(fp, argv[0]) + fshut(stdin, "<stdin>") +
fshut(stdout, "<stdout>"));
}

19
paste.c
View File

@ -88,7 +88,7 @@ main(int argc, char *argv[])
struct fdescr *dsc;
Rune *delim;
size_t i, len;
int seq = 0;
int seq = 0, ret = 0;
char *adelim = "\t";
ARGBEGIN {
@ -116,22 +116,23 @@ main(int argc, char *argv[])
dsc = ereallocarray(NULL, argc, sizeof(*dsc));
for (i = 0; i < argc; i++) {
if (!strcmp(argv[i], "-"))
if (!strcmp(argv[i], "-")) {
dsc[i].fp = stdin;
else
dsc[i].fp = fopen(argv[i], "r");
if (!dsc[i].fp)
} else if (!(dsc[i].fp = fopen(argv[i], "r"))) {
eprintf("fopen %s:", argv[i]);
}
dsc[i].name = argv[i];
}
if (seq)
if (seq) {
sequential(dsc, argc, delim, len);
else
} else {
parallel(dsc, argc, delim, len);
}
for (i = 0; i < argc; i++)
fclose(dsc[i].fp);
if (dsc[i].fp != stdin && fshut(dsc[i].fp, argv[i]))
ret = 1;
return 0;
return fshut(stdin, "<stdin>") || fshut(stdout, "<stdout>") || ret;
}

View File

@ -35,5 +35,5 @@ main(int argc, char *argv[])
}
}
return ret;
return fshut(stdout, "<stdout>") || ret;
}

View File

@ -152,5 +152,5 @@ main(int argc, char *argv[])
cooldown = 1;
}
return 0;
return fshut(stdout, "<stdout>");
}

2
pwd.c
View File

@ -46,5 +46,5 @@ main(int argc, char *argv[])
eprintf("getcwd:");
puts((mode == 'L') ? getpwd(cwd) : cwd);
return 0;
return fshut(stdout, "<stdout>");
}

View File

@ -91,5 +91,5 @@ mdone:
if (!nflag)
putchar('\n');
return 0;
return fshut(stdout, "<stdout>");
}

13
sed.c
View File

@ -433,8 +433,7 @@ compile(char *s, int isfile)
}
}
if (fclose(f))
weprintf("fclose:");
fshut(f, s);
}
/* FIXME: if we decide to honor lack of trailing newline, set/clear a global
@ -1119,8 +1118,8 @@ next_file(void)
if (file == stdin)
clearerr(file);
else if (file && fclose(file))
weprintf("fclose:");
if (file)
fshut(file, "<file>");
file = NULL;
do {
@ -1188,8 +1187,7 @@ write_file(char *path, FILE *out)
while (read_line(in, &genbuf) != EOF)
check_puts(genbuf.str, out);
if (fclose(in))
weprintf("fclose:");
fshut(in, path);
}
static void
@ -1730,5 +1728,6 @@ main(int argc, char *argv[])
files = argv;
run();
return 0;
return !!(fshut(stdin, "<stdin>") + fshut(stdout, "<stdout>"));
}

2
seq.c
View File

@ -143,5 +143,5 @@ main(int argc, char *argv[])
}
putchar('\n');
return 0;
return fshut(stdout, "<stdout>");
}

View File

@ -34,5 +34,6 @@ main(int argc, char *argv[])
usage();
} ARGEND;
return cryptfunc(argc, argv, &sha1_ops, md, sizeof(md));
return cryptfunc(argc, argv, &sha1_ops, md, sizeof(md)) ||
!!(fshut(stdin, "<stdin>") + fshut(stdout, "<stdout>"));
}

View File

@ -34,5 +34,6 @@ main(int argc, char *argv[])
usage();
} ARGEND;
return cryptfunc(argc, argv, &sha256_ops, md, sizeof(md));
return cryptfunc(argc, argv, &sha256_ops, md, sizeof(md)) ||
!!(fshut(stdin, "<stdin>") + fshut(stdout, "<stdout>"));
}

View File

@ -34,5 +34,6 @@ main(int argc, char *argv[])
usage();
} ARGEND;
return cryptfunc(argc, argv, &sha512_ops, md, sizeof(md));
return cryptfunc(argc, argv, &sha512_ops, md, sizeof(md)) ||
!!(fshut(stdin, "<stdin>") + fshut(stdout, "<stdout>"));
}

9
sort.c
View File

@ -236,7 +236,7 @@ main(int argc, char *argv[])
FILE *fp, *ofp = stdout;
struct linebuf linebuf = EMPTY_LINEBUF;
size_t i;
int global_flags = 0;
int global_flags = 0, ret = 0;
char *outfile = NULL;
ARGBEGIN {
@ -300,7 +300,8 @@ main(int argc, char *argv[])
} else {
getlines(fp, &linebuf);
}
fclose(fp);
if (fshut(fp, *argv))
ret = 1;
}
if (!Cflag && !cflag) {
@ -318,5 +319,7 @@ main(int argc, char *argv[])
}
}
return 0;
enfshut(2, stdin, "<stdin>");
enfshut(2, stdout, "<stdout>");
return ret;
}

View File

@ -27,7 +27,7 @@ nextfile(FILE *f, char *buf, int plen, int slen)
static int filecount = 0;
if (f)
fclose(f);
fshut(f, "<file>");
if (itostr(buf + plen, filecount++, slen) < 0)
return NULL;
@ -124,9 +124,6 @@ main(int argc, char *argv[])
putc(ch, out);
}
fclose(in);
if (out)
fclose(out);
return 0;
return !!(fshut(in, "<infile>") + (out && fshut(out, "<outfile>")) +
fshut(stdin, "<stdin>") + fshut(stdout, "<stdout>"));
}

View File

@ -32,8 +32,5 @@ main(int argc, char *argv[])
eprintf("fopen %s:", argv[0]);
concat(tmpfp, "<tmpfile>", fp, argv[0]);
fclose(fp);
fclose(tmpfp);
return 0;
return !!(fshut(fp, argv[0]) + fshut(tmpfp, "<tmpfile>"));
}

View File

@ -85,9 +85,10 @@ main(int argc, char *argv[])
continue;
}
strings(fp, *argv, len);
fclose(fp);
if (fshut(fp, *argv))
ret = 1;
}
}
return ret;
return !!(fshut(stdin, "<stdin>") + fshut(stdout, "<stdout>")) || ret;
}

5
tail.c
View File

@ -130,7 +130,8 @@ main(int argc, char *argv[])
tail(fp, *argv);
if (!fflag) {
fclose(fp);
if (fshut(fp, *argv))
ret = 1;
continue;
}
for (tmp = NULL, tmpsize = 0;;) {
@ -155,5 +156,5 @@ main(int argc, char *argv[])
}
}
return ret;
return !!(fshut(stdin, "<stdin>") + fshut(stdout, "<stdout>")) || ret;
}

7
tar.c
View File

@ -166,8 +166,7 @@ archive(const char *path)
if (fwrite(b, BLKSIZ, 1, tarfile) != 1)
eprintf("fwrite:");
}
if (fclose(f) == EOF)
eprintf("fclose %s:", path);
efshut(f, path);
}
return 0;
@ -246,8 +245,8 @@ unarchive(char *fname, ssize_t l, char b[BLKSIZ])
if (f && fwrite(b, MIN(l, BLKSIZ), 1, f) != 1)
eprintf("fwrite %s:", fname);
}
if (f && fclose(f) == EOF)
eprintf("fclose %s:", fname);
if (f)
fshut(f, fname);
if (!mflag) {
times[0].tv_sec = times[1].tv_sec = mtime;

4
tee.c
View File

@ -46,8 +46,6 @@ main(int argc, char *argv[])
eprintf("fwrite %s:", (i != argc) ? argv[i] : "<stdout>");
}
}
if (ferror(stdin))
eprintf("fread <stdin>:");
return 0;
return !!(fshut(stdin, "<stdin>") + fshut(stdout, "<stdout>"));
}

2
tr.c
View File

@ -204,7 +204,7 @@ main(int argc, char *argv[])
eprintf("set2 can't be imaged to from a complement.\n");
read:
if (!efgetrune(&r, stdin, "<stdin>"))
return 0;
return !!(fshut(stdin, "<stdin>") + fshut(stdout, "<stdout>"));
off1 = off2 = 0;
for (i = 0; i < set1ranges; i++) {
if (set1[i].start <= r && r <= set1[i].end) {

2
tty.c
View File

@ -26,5 +26,5 @@ main(int argc, char *argv[])
tty = ttyname(STDIN_FILENO);
puts(tty ? tty : "not a tty");
return !tty;
return fshut(stdout, "<stdout>") || !tty;
}

View File

@ -55,5 +55,5 @@ main(int argc, char *argv[])
putword(u.machine);
putchar('\n');
return 0;
return fshut(stdout, "<stdout>");
}

View File

@ -159,7 +159,8 @@ main(int argc, char *argv[])
continue;
}
unexpand(*argv, fp);
fclose(fp);
if (fshut(fp, *argv))
ret = 1;
}
}

5
uniq.c
View File

@ -131,10 +131,9 @@ main(int argc, char *argv[])
eprintf("fopen %s:", argv[1]);
}
uniq(fp, ofp);
fclose(fp);
}
uniqfinish(ofp);
fclose(ofp);
return 0;
return !!(fshut(fp, fp == stdin ? "<stdin>" : argv[0]) +
fshut(ofp, ofp == stdout ? "<stdout>" : argv[1]));
}

5
util.h
View File

@ -3,6 +3,7 @@
#include <regex.h>
#include <stddef.h>
#include <stdio.h>
#include "arg.h"
#include "compat.h"
@ -34,6 +35,10 @@ void *enrealloc(int, void *, size_t);
char *enstrdup(int, const char *);
char *enstrndup(int, const char *, size_t);
void enfshut(int, FILE *, const char *);
void efshut(FILE *, const char *);
int fshut(FILE *, const char *);
void enprintf(int, const char *, ...);
void eprintf(const char *, ...);
void weprintf(const char *, ...);

View File

@ -273,10 +273,7 @@ main(int argc, char *argv[])
if (nfp != stdout && chmod(fname, mode) < 0)
eprintf("chmod %s:", fname);
if (fp)
fclose(fp);
if (nfp)
fclose(nfp);
return 0;
return !!(fshut(fp, fp == stdin ? "<stdin>" : argv[0]) +
fshut(nfp, nfp == stdout ? "<stdout>" : fname));
}

View File

@ -101,7 +101,7 @@ usage(void)
int
main(int argc, char *argv[])
{
FILE *fp;
FILE *fp = NULL;
ARGBEGIN {
case 'm':
@ -126,8 +126,8 @@ main(int argc, char *argv[])
uuencodeb64(fp, argv[1], argv[0]);
else
uuencode(fp, argv[1], argv[0]);
fclose(fp);
}
return 0;
return !!((fp && fshut(fp, argv[0])) + fshut(stdin, "<stdin>") +
fshut(stdout, "<stdout>"));
}

5
wc.c
View File

@ -91,11 +91,12 @@ main(int argc, char *argv[])
continue;
}
wc(fp, *argv);
fclose(fp);
if (fshut(fp, *argv))
ret = 1;
}
if (many)
output("total", tc, tl, tw);
}
return ret;
return !!(fshut(stdin, "<stdin>") + fshut(stdout, "<stdout>")) || ret;
}

View File

@ -269,5 +269,6 @@ main(int argc, char *argv[])
free(argb);
return nerrors ? 123 : 0;
return (nerrors || !!(fshut(stdin, "<stdin>") +
fshut(stdout, "<stdout>"))) ? 123 : 0;
}