Skip to content

Commit

Permalink
Minor fix for NetBSD
Browse files Browse the repository at this point in the history
  • Loading branch information
ricardobranco777 committed Feb 11, 2024
1 parent 1882829 commit 1d66493
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 16 deletions.
1 change: 1 addition & 0 deletions bsd/extern.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@ void free_argv(char **);
char **kinfo_getargv(pid_t pid);

#ifdef __NetBSD__
#define kinfo_proc kinfo_proc2
struct kinfo_proc *kinfo_getallproc(int *);
#endif
9 changes: 3 additions & 6 deletions bsd/kinfo_getallproc.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,6 @@
#include <sys/proc.h>
#include <stdlib.h>

#if defined(__NetBSD__)
#define kinfo_proc kinfo_proc2
#endif

#include "extern.h"

/*
Expand Down Expand Up @@ -39,13 +35,13 @@ kinfo_getallproc(int *cntp)
mib[1] = KERN_PROC2;
mib[2] = KERN_PROC_ALL;
mib[3] = 0;
mib[4] = sizeof(struct kinfo_proc2);
mib[4] = sizeof(struct kinfo_proc);
mib[5] = 0;

len = 0;
if (sysctl(mib, 6, NULL, &len, NULL, 0) < 0)
return (NULL);
mib[5] = (int) (len / sizeof(struct kinfo_proc2));
mib[5] = (int) (len / sizeof(struct kinfo_proc));

kipp = malloc(len);
if (kipp == NULL)
Expand All @@ -56,6 +52,7 @@ kinfo_getallproc(int *cntp)
*cntp = len / sizeof(*kipp);
kinfo_proc_sort(kipp, len / sizeof(*kipp));
return (kipp);

bad:
*cntp = 0;
free(kipp);
Expand Down
14 changes: 4 additions & 10 deletions bsd/restartable.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,6 @@
* SUCH DAMAGE.
*/

#ifdef __NetBSD__
/* struct kinfo_proc */
#define _KMEMUSER
#endif

#include <sys/types.h>
#if defined(__FreeBSD__)
#include <sys/user.h>
Expand All @@ -51,12 +46,11 @@
#include <vis.h>

#if defined(__NetBSD__)
#define kinfo_proc kinfo_proc2
#define ki_comm p_comm
#define ki_comm p_comm
#define ki_login p_login
#define ki_pid p_pid
#define ki_ppid p_ppid
#define ki_ruid p_ruid
#define ki_pid p_pid
#define ki_ppid p_ppid
#define ki_ruid p_ruid
#endif

#include "extern.h"
Expand Down

0 comments on commit 1d66493

Please sign in to comment.