void real_mgettimeofday(struct timeval *tv);
void mrename(const char *old, const char *new);
+void mwaitpid(pid_t child, const char *what);
void badusage(const char *why);
/*---------- finding and interpreting of old persistent data ----------*/
static int persist_convert(const char *data, const char *conv) {
- int data_fd, newrecord_fd, status;
- pid_t child, rpid;
+ int data_fd, newrecord_fd;
+ pid_t child;
if (!fe(conv)) return 0;
execl(conv, conv, PERSIST_CONVERT_OPTION, (char*)0);
diee("persist child: failed to exec `%s'", conv);
}
-
- rpid= waitpid(child,&status,0); if (rpid!=child) diee("waitpid");
- if (WIFEXITED(status)) {
- int st= WEXITSTATUS(status);
- if (st) die("persist conversion exited with nonzero status %d",st);
- } else if (WIFSIGNALED(status)) {
- die("persist conversion died due to %s%s",
- strsignal(WTERMSIG(status)),
- WCOREDUMP(status) ? " (core dumped)" : "");
- } else {
- die("persist conversion failed with unexpected wait status 0x%x",status);
- }
+
+ mwaitpid(child, "persist conversion");
if (close(newrecord_fd)) diee("persist data close new record");
close(data_fd);
#include <ctype.h>
#include <math.h>
-#include <sys/types.h>
#include <sys/time.h>
#include <sys/stat.h>
#include <sys/mman.h>
-#include <sys/wait.h>
#include <unistd.h>
#include <fcntl.h>
/*---------- CPU: set hard scheduling priority ----------*/
static void rtf_acquire_CPU(void) {
- struct sched_param sp;
- int r;
-
- sp.sched_priority= 10;
- r= sched_setscheduler(0, SCHED_FIFO, &sp);
- if (r) diee("sched_setscheduler");
+ pid_t child;
+
+ child= fork();
+ if (child<0) diee("fork for auth-sched-setscheduler");
+
+ if (!child) {
+ execlp("auth-sched-setscheduler",
+ "auth-sched-setscheduler","fifo",10,(char*)0);
+ diee("exec auth-sched-setscheduler");
+ }
+ mwaitpid(child, "auth-sched-setscheduler");
}
/*---------- core ----------*/
#include <stdio.h>
#include <stdlib.h>
+#include <sys/types.h>
+#include <sys/wait.h>
+
#include "common.h"
static void vdie_vprintf(const char *fmt, va_list al) {
if (rename(old,new))
diee("failed to rename `%s' to `%s'", old,new);
}
+
+void mwaitpid(pid_t child, const char *what) {
+ pid_t rpid;
+ int status;
+
+ rpid= waitpid(child,&status,0); if (rpid!=child) diee("waitpid");
+ if (WIFEXITED(status)) {
+ int st= WEXITSTATUS(status);
+ if (st) die("%s exited with nonzero status %d",what,st);
+ } else if (WIFSIGNALED(status)) {
+ die("%s died due to %s%s", what, strsignal(WTERMSIG(status)),
+ WCOREDUMP(status) ? " (core dumped)" : "");
+ } else {
+ die("%s failed with unexpected wait status 0x%x", what, status);
+ }
+}