#include <fcntl.h>
#include <signal.h>
-#include <sys/wait.h>
+#ifndef WIN32
+# include <sys/wait.h>
+#endif
#include <unistd.h>
#if HAVE_SYS_MOUNT_H
# include <sys/mount.h>
"rr",
);
+
+#ifndef WIN32
/**
* virProcessTranslateStatus:
* @status: child exit status to translate
}
-#ifndef WIN32
/**
* virProcessAbort:
* @pid: child process to kill
cleanup:
errno = saved_errno;
}
-#else
-void
-virProcessAbort(pid_t pid)
-{
- /* Not yet ported to mingw. Any volunteers? */
- VIR_DEBUG("failed to reap child %lld, abandoning it", (long long)pid);
-}
-#endif
/**
return -1;
}
+#else /* WIN32 */
+
+char *
+virProcessTranslateStatus(int status)
+{
+ return g_strdup_printf(_("invalid value %d"), status);
+}
+
+
+void
+virProcessAbort(pid_t pid)
+{
+ /* Not yet ported to mingw. Any volunteers? */
+ VIR_DEBUG("failed to reap child %lld, abandoning it", (long long)pid);
+}
+
+
+int
+virProcessWait(pid_t pid, int *exitstatus G_GNUC_UNUSED, bool raw G_GNUC_UNUSED)
+{
+ virReportSystemError(ENOSYS, _("unable to wait for process %lld"),
+ (long long) pid);
+ return -1;
+}
+
+#endif /* WIN32 */
+
/* send signal to a single process */
int virProcessKill(pid_t pid, int sig)
#endif
+#ifdef __linux__
typedef struct _virProcessNamespaceHelperData virProcessNamespaceHelperData;
struct _virProcessNamespaceHelperData {
pid_t pid;
return virProcessRunInFork(virProcessNamespaceHelper, &data);
}
+#else /* ! __linux__ */
+int
+virProcessRunInMountNamespace(pid_t pid G_GNUC_UNUSED,
+ virProcessNamespaceCallback cb G_GNUC_UNUSED,
+ void *opaque G_GNUC_UNUSED)
+{
+ virReportSystemError(ENOSYS, "%s",
+ _("Namespaces are not supported on this platform"));
+ return -1;
+}
+
+#endif /* ! __linux__ */
+
+
+#ifndef WIN32
static int
virProcessRunInForkHelper(int errfd,
pid_t ppid,
return ret;
}
+#else /* WIN32 */
+
+int
+virProcessRunInFork(virProcessForkCallback cb G_GNUC_UNUSED,
+ void *opaque G_GNUC_UNUSED)
+{
+ virReportSystemError(ENOSYS, "%s",
+ _("Process spawning is not supported on this platform"));
+ return -1;
+}
+
+#endif /* WIN32 */
-#if defined(HAVE_SYS_MOUNT_H) && defined(HAVE_UNSHARE)
+
+#if defined(__linux__)
int
virProcessSetupPrivateMountNS(void)
{
return 0;
}
-#else /* !defined(HAVE_SYS_MOUNT_H) || !defined(HAVE_UNSHARE) */
-
-int
-virProcessSetupPrivateMountNS(void)
-{
- virReportSystemError(ENOSYS, "%s",
- _("Namespaces are not supported on this platform."));
- return -1;
-}
-#endif /* !defined(HAVE_SYS_MOUNT_H) || !defined(HAVE_UNSHARE) */
-#if defined(__linux__)
G_GNUC_NORETURN static int
virProcessDummyChild(void *argv G_GNUC_UNUSED)
{
_exit(0);
}
+
/**
* virProcessNamespaceAvailable:
* @ns: what namespaces to check (bitwise-OR of virProcessNamespaceFlags)
#else /* !defined(__linux__) */
+int
+virProcessSetupPrivateMountNS(void)
+{
+ virReportSystemError(ENOSYS, "%s",
+ _("Namespaces are not supported on this platform."));
+ return -1;
+}
+
int
virProcessNamespaceAvailable(unsigned int ns G_GNUC_UNUSED)
{
_("Namespaces are not supported on this platform."));
return -1;
}
+
#endif /* !defined(__linux__) */
/**
{
int value = EXIT_CANNOT_INVOKE;
+#ifndef WIN32
if (WIFEXITED(status)) {
value = WEXITSTATUS(status);
} else if (WIFSIGNALED(status)) {
raise(WTERMSIG(status));
value = 128 + WTERMSIG(status);
}
+#else /* WIN32 */
+ (void)status;
+#endif /* WIN32 */
exit(value);
}