#include "libpspp/str.h"
#include "libpspp/string-array.h"
#include "libpspp/temp-file.h"
-#include "output/text-item.h"
+#include "output/output-item.h"
#include "gl/error.h"
#include "gl/intprops.h"
{
/* Running in the child. */
+#if __GNU__
+ /* Hurd doesn't support inheriting process timers in a way that works. */
+ if (setpgid (0, 0) < 0)
+ error (1, errno, _("Failed to set process group."));
+#else
/* Set up timeout. */
if (timeout.tv_sec < TYPE_MAXIMUM (time_t))
{
if (setitimer (ITIMER_REAL, &it, NULL) < 0)
error (1, errno, _("Failed to set timeout."));
}
+#endif
/* Set up file descriptors:
- /dev/null for stdin
int error = 0;
for (;;)
{
- pid_t retval = waitpid (pid, &status, 0);
+#if __GNU__
+ if (timespec_cmp (current_timespec (), timeout) >= 0)
+ kill (-pid, SIGALRM);
+
+ int flags = WNOHANG;
+#else
+ int flags = 0;
+#endif
+ pid_t retval = waitpid (pid, &status, flags);
if (retval == pid)
break;
else if (retval < 0)
break;
}
}
+#if __GNU__
+ else if (retval == 0)
+ sleep (1);
+#endif
else
NOT_REACHED ();
}
if (end > output && end[-1] == '\n')
end[-1] = '\0';
- text_item_submit (text_item_create_nocopy (TEXT_ITEM_LOG, output));
+ output_item_submit (text_item_create_nocopy (TEXT_ITEM_LOG, output,
+ xstrdup (_("Host Output"))));
}
free (locale_output);