From 5c4c368610c1cfa2bb2793b8f7463b413e79cb2c Mon Sep 17 00:00:00 2001 From: Jakob Kaivo Date: Fri, 19 Jul 2019 15:18:50 -0400 Subject: properly clean up --- mktemp.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/mktemp.c b/mktemp.c index 14d615c..556d452 100644 --- a/mktemp.c +++ b/mktemp.c @@ -1,4 +1,5 @@ -#define _POSIX_C_SOURCE 200809L +#define _XOPEN_SOURCE +#define _XOPEN_SOURCE_EXTENDED #include #include #include @@ -14,7 +15,8 @@ int main(int argc, char *argv[]) fprintf(stderr, "template must contain at least six 'X' characters\n"); return 1; } - rmdir(template); - printf("%s\n", mkdtemp(template)); + close(mkstemp(template)); + unlink(template); + printf("%s\n", template); return 0; } -- cgit v1.2.1