|  | 
| 8 | 8 | #include <string.h> | 
| 9 | 9 | #include <unistd.h> | 
| 10 | 10 | 
 | 
| 11 |  | -#ifdef __FreeBSD__ | 
|  | 11 | +#if __FreeBSD__ | 
| 12 | 12 |     #include <sys/sysctl.h> | 
| 13 | 13 |     #include <sys/types.h> | 
| 14 | 14 |     #include <sys/user.h> | 
| 15 |  | -#elif defined(__OpenBSD__) | 
|  | 15 | +#elif __OpenBSD__ | 
| 16 | 16 |     #include <sys/param.h> | 
| 17 | 17 |     #include <sys/sysctl.h> | 
| 18 | 18 |     #include <kvm.h> | 
| 19 |  | -#elif defined(__sun) | 
|  | 19 | +#elif __sun | 
| 20 | 20 |     #include <procfs.h> | 
|  | 21 | +#elif __NetBSD__ | 
|  | 22 | +    #include <sys/types.h> | 
|  | 23 | +    #include <sys/sysctl.h> | 
| 21 | 24 | #endif | 
| 22 | 25 | 
 | 
| 23 | 26 | static const char* parseEnv(void) | 
| @@ -388,6 +391,29 @@ static const char* getFromProcesses(FFDisplayServerResult* result) | 
| 388 | 391 |         if(result->wmPrettyName.length == 0) | 
| 389 | 392 |             applyNameIfWM(result, processName.chars); | 
| 390 | 393 | 
 | 
|  | 394 | +        if(result->dePrettyName.length > 0 && result->wmPrettyName.length > 0) | 
|  | 395 | +            break; | 
|  | 396 | +    } | 
|  | 397 | +#elif __NetBSD__ | 
|  | 398 | +    int request[] = {CTL_KERN, KERN_PROC2, KERN_PROC_UID, (int) userId, sizeof(struct kinfo_proc2), INT_MAX}; | 
|  | 399 | + | 
|  | 400 | +    size_t size = 0; | 
|  | 401 | +    if(sysctl(request, ARRAY_SIZE(request), NULL, &size, NULL, 0) != 0) | 
|  | 402 | +        return "sysctl(KERN_PROC_UID, NULL) failed"; | 
|  | 403 | + | 
|  | 404 | +    FF_AUTO_FREE struct kinfo_proc2* procs = malloc(size); | 
|  | 405 | + | 
|  | 406 | +    if(sysctl(request, ARRAY_SIZE(request), procs, &size, NULL, 0) != 0) | 
|  | 407 | +        return "sysctl(KERN_PROC_UID, procs) failed"; | 
|  | 408 | + | 
|  | 409 | +    for(struct kinfo_proc2* proc = procs; proc < procs + (size / sizeof(struct kinfo_proc2)); proc++) | 
|  | 410 | +    { | 
|  | 411 | +        if(result->dePrettyName.length == 0) | 
|  | 412 | +            applyPrettyNameIfDE(result, proc->p_comm); | 
|  | 413 | + | 
|  | 414 | +        if(result->wmPrettyName.length == 0) | 
|  | 415 | +            applyNameIfWM(result, proc->p_comm); | 
|  | 416 | + | 
| 391 | 417 |         if(result->dePrettyName.length > 0 && result->wmPrettyName.length > 0) | 
| 392 | 418 |             break; | 
| 393 | 419 |     } | 
|  | 
0 commit comments