summaryrefslogtreecommitdiff
path: root/src/libposixplz/mkptemp.c
blob: 42bc715ba72646149080ee3bac1b2131b84c55a5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
/* ISC license. */

#include <sys/stat.h>

#include <skalibs/djbunix.h>
#include <skalibs/posixplz.h>

static int f (char const *fn, mode_t mode, void *data)
{
  int r = mkfifo(fn, mode) ;
  if (r == -1) return -1 ;
  r = open_readb(fn) ;
  if (r == -1) unlink_void(fn) ;
  return r ;
}

int mkptemp (char *s)
{
  return mkfiletemp(s, &f, 0600, 0) ;
}