| * Copyright (C) 2012 Sami Kerola <kerolasa@iki.fi> |
| #include <sys/resource.h> |
| /* Create open temporary file in safe way. Please notice that the |
| * file permissions are -rw------- by default. */ |
| int xmkstemp(char **tmpname, char *dir) |
| /* Some use cases must be capable of being moved atomically |
| * with rename(2), which is the reason why dir is here. */ |
| tmpenv = getenv("TMPDIR"); |
| xasprintf(&localtmp, "%s/%s.XXXXXX", tmpenv, |
| program_invocation_short_name); |
| xasprintf(&localtmp, "%s/%s.XXXXXX", _PATH_TMP, |
| program_invocation_short_name); |
| * portable getdtablesize() |
| #if defined(HAVE_GETDTABLESIZE) |
| #elif defined(HAVE_GETRLIMIT) && defined(RLIMIT_NOFILE) |
| getrlimit(RLIMIT_NOFILE, &rl); |
| #elif defined(HAVE_SYSCONF) && defined(_SC_OPEN_MAX) |
| m = sysconf(_SC_OPEN_MAX); |
| f = xfmkstemp(&tmpname, NULL); |