rpcgen(1): Check getrlimit() return for generated code.

Obtained from:	NetBSD (CVS rev 1.27, 1.28)
MFC after:	1 week
This commit is contained in:
Pedro F. Giffuni 2017-01-12 14:44:41 +00:00
parent 062a4b8c68
commit f5ab496e62
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=311981

View file

@ -728,7 +728,8 @@ write_timeout_func(void)
if (tirpcflag) {
f_print(fout, "\t\t\tstruct rlimit rl;\n\n");
f_print(fout, "\t\t\trl.rlim_max = 0;\n");
f_print(fout, "\t\t\tgetrlimit(RLIMIT_NOFILE, &rl);\n");
f_print(fout, "\t\t\tif (getrlimit(RLIMIT_NOFILE, &rl) == -1)\n");
f_print(fout, "\t\t\t\treturn;\n");
f_print(fout, "\t\t\tif ((size = rl.rlim_max) == 0) {\n");
if (mtflag)
@ -902,7 +903,11 @@ write_rpc_svc_fg(const char *infile, const char *sp)
/* get number of file descriptors */
if (tirpcflag) {
f_print(fout, "%srl.rlim_max = 0;\n", sp);
f_print(fout, "%sgetrlimit(RLIMIT_NOFILE, &rl);\n", sp);
f_print(fout, "%sif (getrlimit(RLIMIT_NOFILE, &rl) == -1) {\n",
sp);
f_print(fout, "%s\tperror(\"getrlimit\");\n", sp);
f_print(fout, "%s\texit(1);\n", sp);
f_print(fout, "%s}\n", sp);
f_print(fout, "%sif ((size = rl.rlim_max) == 0)\n", sp);
f_print(fout, "%s\texit(1);\n", sp);
} else {