#include "passfd.h"
#include <fcntl.h>
+#include <signal.h>
#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <sys/stat.h>
+#include <sys/wait.h>
#include "macros.h"
int fd;
struct stat st;
+#if HAVE_DECL_ALARM
+ /* Avoid hanging on failure. */
+ signal (SIGALRM, SIG_DFL);
+ alarm (5);
+#endif
+
fdnull = open ("/dev/null", O_RDWR);
if (fdnull < 0)
{
}
ASSERT (ret == pid);
- ret = WIFEXITED (status);
- if (ret == 0)
+ if (!WIFEXITED (status))
{
fprintf (stderr, "Child does not normally exit\n");
return 65;
}
/* try to stat new fd */
- ret == fstat (fd, &st);
- if (0 != ret)
+ ret = fstat (fd, &st);
+ if (ret < 0)
{
perror ("fstat");
return 80;