summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--mktemp.c8
1 files 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 <stdio.h>
#include <string.h>
#include <stdlib.h>
@@ -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;
}