Build and program starting fixes

This commit is contained in:
Michal Moskal
2017-07-25 14:59:32 +01:00
parent de180e97aa
commit bcf597143a
6 changed files with 17 additions and 21 deletions

View File

@ -666,21 +666,26 @@ void stopLMS() {
closedir(dir);
if (lmsPid) {
DBG("SIGSTOP to lmsPID=%d", lmsPid);
DBG("SIGSTOP to lmsPID=%d\n", lmsPid);
kill(lmsPid, SIGSTOP);
} else {
DBG("LMS not found\n");
}
}
void waitAndContinue() {
stopLMS();
for (int fd = 3; fd < 9999; ++fd)
close(fd);
pid_t child = fork();
if (child == 0) {
execl(elfPath, elfPath, "--msd");
DBG("start %s\n", elfPath);
execl(elfPath, elfPath, "--msd", (char*) NULL);
exit(128);
}
int status;
waitpid(child, &status, 0);
DBG("re-start LMS\n");
if (lmsPid)
kill(lmsPid, SIGCONT);
exit(0);

View File

@ -133,6 +133,7 @@ void runNBD() {
reply.error = htonl(0);
for (;;) {
nbd_ioctl(BLKFLSBUF, 0); // flush buffers - we don't want the kernel to cache the writes
int nread = read(sock, &request, sizeof(request));
if (nread < 0) {
@ -199,7 +200,9 @@ int main() {
if (!WIFEXITED(wstatus) || WEXITSTATUS(wstatus) != 0) {
LOG("abnormal child return, %d", child);
sleep(3);
sleep(5);
} else {
sleep(2);
}
}