/* mkstemp.c */

#include <stdio.h>
#include <unistd.h>


static void recurse (void)
{
  int fd;
  char template[20];

  strcpy (template, "mtXXXXXX");
  fd = mkstemp (template);
  if (fd >= 0)
    {
      printf ("mkstemp -> %s %d\n", template, fd);
      recurse ();
      if (close (fd) != 0)
        perror ("close()");
      if (remove (template) != 0)
        perror ("remove()");
    }
  else
    perror ("mkstemp()");
}


int main (void)
{
  recurse ();
  return 0;
}
