| 220 | } |
| 221 | |
| 222 | int tmpdir_mkstemp(const tal_t *ctx, const char *template TAKES, char **created) |
| 223 | { |
| 224 | char *tmpdir = getenv("TMPDIR"); |
| 225 | char *path = path_join(ctx, tmpdir ?: "/tmp", template); |
| 226 | int fd = mkstemp(path); |
| 227 | |
| 228 | if (fd >= 0) |
| 229 | *created = path; |
| 230 | else |
| 231 | tal_free(path); |
| 232 | |
| 233 | return fd; |
| 234 | } |