Revision ce798cf2 os-posix.c

b/os-posix.c
37 37
#include "net/slirp.h"
38 38
#include "qemu-options.h"
39 39

  
40
#ifdef CONFIG_LINUX
41
#include <sys/prctl.h>
42
#endif
43

  
40 44
static struct passwd *user_pwd;
41 45
static const char *chroot_dir;
42 46
static int daemonize;
......
139 143
#undef SHARE_SUFFIX
140 144
#undef BUILD_SUFFIX
141 145

  
146
void os_set_proc_name(const char *s)
147
{
148
#if defined(PR_SET_NAME)
149
    char name[16];
150
    if (!s)
151
        return;
152
    name[sizeof(name) - 1] = 0;
153
    strncpy(name, s, sizeof(name));
154
    /* Could rewrite argv[0] too, but that's a bit more complicated.
155
       This simple way is enough for `top'. */
156
    if (prctl(PR_SET_NAME, name)) {
157
        perror("unable to change process name");
158
        exit(1);
159
    }
160
#else
161
    fprintf(stderr, "Change of process name not supported by your OS\n");
162
    exit(1);
163
#endif
164
}
165

  
142 166
/*
143 167
 * Parse OS specific command line options.
144 168
 * return 0 if option handled, -1 otherwise

Also available in: Unified diff