Skip to content

Commit 20f06ad

Browse files
committed
[freebsd] let LTbasic2 work on FreeBSD 14.3
Use explicit stat() to let kernel remember the path so that liblsof can read it later.
1 parent 054198c commit 20f06ad

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

tests/LTbasic2.c

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ int main(int argc, char **argv) {
5050
char buffer[128];
5151
struct stat exec_stat;
5252
struct stat cwd_stat;
53+
struct stat tmp_stat;
5354
int fd;
5455
int round;
5556
int exec_found; /* executable found in result */
@@ -77,6 +78,10 @@ int main(int argc, char **argv) {
7778
"Cannot create 'LTbasic2-tmp' in current directory, "
7879
"skipping fd check\n");
7980
fd_found = 1;
81+
} else {
82+
/* on FreeBSD 14.3, the path for newly created file is not returned
83+
* immediately, so let's trigger it */
84+
stat("LTbasic2-tmp", &tmp_stat);
8085
}
8186

8287
ctx = lsof_new();
@@ -135,7 +140,10 @@ int main(int argc, char **argv) {
135140
fprintf(stderr, "ERROR!!! opened regular file wasn't found.\n");
136141
}
137142
/* cleanup created temporary file */
138-
unlink("LTbasic2-tmp");
143+
if (fd >= 0) {
144+
close(fd);
145+
unlink("LTbasic2-tmp");
146+
}
139147
if (!(exec_found && cwd_found && fd_found)) {
140148
return 1;
141149
}

0 commit comments

Comments
 (0)