Skip to content

Instantly share code, notes, and snippets.

@sgraham
Created October 23, 2020 23:54
Show Gist options
  • Select an option

  • Save sgraham/af5fe768a627061a0257fe4f89a718d7 to your computer and use it in GitHub Desktop.

Select an option

Save sgraham/af5fe768a627061a0257fe4f89a718d7 to your computer and use it in GitHub Desktop.
[scottmg:~]$ pwd
/Users/scottmg
[scottmg:~]$ cat a.c
#include <errno.h>
#include <stdio.h>
#include <sys/stat.h>
#include <unistd.h>
int main() {
for (int count = 0; ; ++count) {
struct stat st;
if (stat("../../usr/bin/env", &st) < 0) {
if (errno == ENOENT || errno == ENOTDIR) {
fprintf(stderr, "got errno: %d (ENOENT=%d, ENOTDIR=%d)\n", errno, ENOENT, ENOTDIR);
char buf[256];
getcwd(buf, sizeof(buf));
fprintf(stderr, "cwd: %s\n", buf);
fprintf(stderr, "count=%d\n", count);
}
return 1;
}
}
return 0;
}
[scottmg:~]$ clang a.c -o a
[scottmg:~]$ ./a
got errno: 2 (ENOENT=2, ENOTDIR=20)
cwd: /Users/scottmg
count=504033
@stolk
Copy link

stolk commented Oct 24, 2020

I was able to repro, although it can take a long time to trigger:

% ./a
got errno: 2 (ENOENT=2, ENOTDIR=20)
cwd: /Users/bram
count=10192178

So far, I've not been able to trigger it running as root.

@sgraham
Copy link
Author

sgraham commented Oct 24, 2020

Ah, thanks for confirming, I was wondering if it was perhaps some internal corp-anti-malware-monitoring thing.

@nico
Copy link

nico commented Mar 2, 2022

I hear this might be getting fixed in macOS 12.3.

@sgraham
Copy link
Author

sgraham commented Mar 2, 2022

👍

But the question is what will break in 12.3 to take its place?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment