Skip to content

Commit

Permalink
Stop checking for being ptrace when starting
Browse files Browse the repository at this point in the history
Comes with overhead and does not buy anything as interested parties can
instead increase debug. Also note the check was FreeBSD-only.

This effectively reverts 22dcc18
  • Loading branch information
mjguzik authored and bapt committed Dec 1, 2022
1 parent 00bf763 commit 6bd64fe
Showing 1 changed file with 1 addition and 30 deletions.
31 changes: 1 addition & 30 deletions src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,6 @@
#include <sys/stat.h>
#include <sys/types.h>
#include <sys/wait.h>
#ifdef __FreeBSD__
#include <sys/sysctl.h>
#include <sys/user.h>
#include <sys/proc.h>
#endif

#include <assert.h>
#include <ctype.h>
Expand Down Expand Up @@ -553,30 +548,6 @@ expand_aliases(int argc, char ***argv)
return (newargc);
}

static
bool ptraced(void)
{
#if defined(__FreeBSD__)
int mib[4];
struct kinfo_proc info;
size_t size;

info.ki_flag = 0;

mib[0] = CTL_KERN;
mib[1] = KERN_PROC;
mib[2] = KERN_PROC_PID;
mib[3] = getpid();

size = sizeof(info);
sysctl(mib, sizeof(mib) / sizeof(*mib), &info, &size, NULL, 0);

return ((info.ki_flag & P_TRACED) != 0 );
#else
return (false);
#endif
}

int
main(int argc, char **argv)
{
Expand Down Expand Up @@ -718,7 +689,7 @@ main(int argc, char **argv)
optreset = 1;
optind = 1;

if (debug == 0 && version == 0 && !ptraced())
if (debug == 0 && version == 0)
start_process_worker(save_argv);

#ifdef HAVE_ARC4RANDOM_STIR
Expand Down

0 comments on commit 6bd64fe

Please sign in to comment.