Skip to content

Commit 4ef754d

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 4308799 commit 4ef754d

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

.cirrus.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ task:
1111
git clone --branch releng/14.3 https://git.FreeBSD.org/src.git /usr/src
1212
fi;
1313
build_script:
14+
- mount
1415
- ./Configure -n freebsd
1516
- make
1617
test_script:

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)