"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "stress-daemon.c" between
stress-ng-0.09.52.tar.xz and stress-ng-0.09.54.tar.xz

About: stress-ng will stress test a computer system in various selectable ways. It was designed to exercise various physical subsystems of a computer as well as the various operating system kernel interfaces.

stress-daemon.c  (stress-ng-0.09.52.tar.xz):stress-daemon.c  (stress-ng-0.09.54.tar.xz)
skipping to change at line 27 skipping to change at line 27
* *
* This code is a complete clean re-write of the stress tool by * This code is a complete clean re-write of the stress tool by
* Colin Ian King <colin.king@canonical.com> and attempts to be * Colin Ian King <colin.king@canonical.com> and attempts to be
* backwardly compatible with the stress tool by Amos Waterland * backwardly compatible with the stress tool by Amos Waterland
* <apw@rossby.metr.ou.edu> but has more stress tests and more * <apw@rossby.metr.ou.edu> but has more stress tests and more
* functionality. * functionality.
* *
*/ */
#include "stress-ng.h" #include "stress-ng.h"
#if defined(NSIG)
#define MAX_SIGNUM NSIG
#elif defined(_NSIG)
#define MAX_SIGNUM _NSIG
#else
#define MAX_SIGNUM 256
#endif
/* /*
* daemons() * daemons()
* fork off a child and let the parent die * fork off a child and let the parent die
*/ */
static void daemons(const args_t *args, const int fd) static void daemons(const args_t *args, const int fd)
{ {
int fds[3]; int fds[3];
int i;
sigset_t set;
if (stress_sig_stop_stressing(args->name, SIGALRM) < 0) if (stress_sig_stop_stressing(args->name, SIGALRM) < 0)
goto err; goto err;
if (setsid() < 0) if (setsid() < 0)
goto err; goto err;
(void)close(0); (void)close(0);
(void)close(1); (void)close(1);
(void)close(2); (void)close(2);
for (i = 0; i < MAX_SIGNUM; i++)
(void)signal(i, SIG_DFL);
(void)sigemptyset(&set);
(void)sigprocmask(SIG_SETMASK, &set, NULL);
#if defined(HAVE_CLEARENV)
(void)clearenv();
#endif
if ((fds[0] = open("/dev/null", O_RDWR)) < 0) if ((fds[0] = open("/dev/null", O_RDWR)) < 0)
goto err; goto err;
if ((fds[1] = dup(0)) < 0) if ((fds[1] = dup(0)) < 0)
goto err0; goto err0;
if ((fds[2] = dup(0)) < 0) if ((fds[2] = dup(0)) < 0)
goto err1; goto err1;
while (g_keep_stressing_flag) { while (g_keep_stressing_flag) {
pid_t pid; pid_t pid;
pid = fork(); pid = fork();
if (pid < 0) { if (pid < 0) {
/* A slow init? no pids or memory, retry */
if ((errno == EAGAIN) || (errno == ENOMEM))
continue;
goto tidy; goto tidy;
} else if (pid == 0) { } else if (pid == 0) {
/* Child */ /* Child */
char buf[1] = { 0xff }; char buf[1] = { 0xff };
ssize_t sz; ssize_t sz;
int ret;
if (chdir("/") < 0) if (chdir("/") < 0)
goto err2; goto err2;
(void)umask(0); (void)umask(0);
ret = stress_drop_capabilities(args->name);
(void)ret;
sz = write(fd, buf, sizeof(buf)); sz = write(fd, buf, sizeof(buf));
if (sz != sizeof(buf)) if (sz != sizeof(buf))
goto err2; goto err2;
} else { } else {
/* Parent, will be reaped by init */ /* Parent, will be reaped by init */
break; break;
} }
} }
 End of changes. 7 change blocks. 
0 lines changed or deleted 28 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)