* libmisc/limits.c: Add brackets and parenthesis.
* libmisc/limits.c: Avoid implicit conversion of pointers / integers to booleans. * libmisc/limits.c: Ignore the return value of umask(). We will never return to the original umask. * libmisc/limits.c: Avoid multi-statements lines. * libmisc/limits.c: Added default to a switch(). Report invalid limit strings to syslog. * libmisc/limits.c: Ignore the return value of fclose(). /etc/limits is open read-only. * libmisc/limits.c: Ignore the return value of fputs() and sleep(). * libmisc/limits.c: Check the return value of nice() and set_filesize_limit(), and report errors to syslog. * libmisc/ulimit.c, lib/prototypes.h: Return failures of set_filesize_limit(). Change the prototype to return an int instead of void.
This commit is contained in:
@@ -50,14 +50,21 @@
|
||||
#endif
|
||||
#include "prototypes.h"
|
||||
|
||||
void set_filesize_limit (int blocks)
|
||||
int set_filesize_limit (int blocks)
|
||||
{
|
||||
int ret = -1;
|
||||
#if HAVE_ULIMIT_H
|
||||
ulimit (UL_SETFSIZE, blocks);
|
||||
if (ulimit (UL_SETFSIZE, blocks) != -1) {
|
||||
ret = 0;
|
||||
}
|
||||
#elif defined(RLIMIT_FSIZE)
|
||||
struct rlimit rlimit_fsize;
|
||||
|
||||
rlimit_fsize.rlim_cur = rlimit_fsize.rlim_max = 512L * blocks;
|
||||
setrlimit (RLIMIT_FSIZE, &rlimit_fsize);
|
||||
rlimit_fsize.rlim_cur = 512L * blocks;
|
||||
rlimit_fsize.rlim_max = rlimit_fsize.rlim_cur;
|
||||
ret = setrlimit (RLIMIT_FSIZE, &rlimit_fsize);
|
||||
#endif
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user