git: 96e139a7a40b - main - devel/apache-commons-daemon: fix bugs in PID handling
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Wed, 24 Dec 2025 09:54:02 UTC
The branch main has been updated by ale:
URL: https://cgit.FreeBSD.org/ports/commit/?id=96e139a7a40b2eadd78ac673c7741de5aec7af8d
commit 96e139a7a40b2eadd78ac673c7741de5aec7af8d
Author: Alex Dupre <ale@FreeBSD.org>
AuthorDate: 2025-12-24 09:52:58 +0000
Commit: Alex Dupre <ale@FreeBSD.org>
CommitDate: 2025-12-24 09:53:57 +0000
devel/apache-commons-daemon: fix bugs in PID handling
---
devel/apache-commons-daemon/Makefile | 1 +
.../files/patch-native_jsvc-unix.c | 50 +++++++++++++++++++---
2 files changed, 44 insertions(+), 7 deletions(-)
diff --git a/devel/apache-commons-daemon/Makefile b/devel/apache-commons-daemon/Makefile
index 1ab02ad7f0c8..a2b026a2a2af 100644
--- a/devel/apache-commons-daemon/Makefile
+++ b/devel/apache-commons-daemon/Makefile
@@ -1,5 +1,6 @@
PORTNAME= commons-daemon
DISTVERSION= 1.5.1
+PORTREVISION= 1
CATEGORIES= devel java
MASTER_SITES= https://archive.apache.org/dist/commons/daemon/source/:src \
https://archive.apache.org/dist/commons/daemon/binaries/:bin
diff --git a/devel/apache-commons-daemon/files/patch-native_jsvc-unix.c b/devel/apache-commons-daemon/files/patch-native_jsvc-unix.c
index 8b2486ff416f..15f5dfe86db5 100644
--- a/devel/apache-commons-daemon/files/patch-native_jsvc-unix.c
+++ b/devel/apache-commons-daemon/files/patch-native_jsvc-unix.c
@@ -1,6 +1,33 @@
---- native/jsvc-unix.c.orig 2025-01-06 00:00:00 UTC
+--- native/jsvc-unix.c.orig 2025-12-11 12:00:00 UTC
+++ native/jsvc-unix.c
-@@ -731,18 +731,13 @@ static int wait_child(arg_data *args, int pid)
+@@ -608,11 +608,12 @@ retry:
+ return 122;
+ }
+ }
+- lseek(fd, SEEK_SET, 0);
+- pidf = fdopen(fd, "r+");
+- fprintf(pidf, "%d\n", (int)getpid());
+- fflush(pidf);
+- fclose(pidf);
++ char buf[32];
++ int len = snprintf(buf, sizeof(buf), "%d\n", (int)getpid());
++ lseek(fd, 0, SEEK_SET);
++ ftruncate(fd, 0);
++ write(fd, buf, len);
++ fsync(fd);
+ if (lockf(fd, F_ULOCK, 0)) {
+ log_error("check_pid: Failed to unlock PID file [%s] with file descriptor [%d] after reading due to [%d]",
+ args->pidf, fd, errno);
+@@ -673,7 +674,7 @@ static int get_pidf(arg_data *args, bool quiet)
+ int i;
+ char buff[80];
+
+- fd = open(args->pidf, O_RDONLY, 0);
++ fd = open(args->pidf, O_RDWR, 0);
+ if (!quiet)
+ log_debug("get_pidf: %d in %s", fd, args->pidf);
+ if (fd < 0) {
+@@ -755,18 +756,13 @@ static int wait_child(arg_data *args, int pid)
*/
static int wait_child(arg_data *args, int pid)
{
@@ -21,7 +48,16 @@
while (count > 0) {
sleep(1);
/* check if the controler is still running */
-@@ -781,7 +776,6 @@ static int wait_child(arg_data *args, int pid)
+@@ -778,7 +774,7 @@ static int wait_child(arg_data *args, int pid)
+ }
+
+ /* check if the pid file process exists */
+- fd = open(args->pidf, O_RDONLY);
++ fd = open(args->pidf, O_RDWR);
+ if (fd < 0 && havejvm) {
+ /* something has gone wrong the JVM has stopped */
+ return 1;
+@@ -812,7 +808,6 @@ static int wait_child(arg_data *args, int pid)
}
}
}
@@ -29,7 +65,7 @@
count--;
}
/* It takes more than the wait time to start,
-@@ -915,11 +909,11 @@ static int child(arg_data *args, home_data *data, uid_
+@@ -946,11 +941,11 @@ static int child(arg_data *args, home_data *data, uid_
create_tmp_file(args);
while (!stopping) {
#if defined(OSD_POSIX)
@@ -43,7 +79,7 @@
#endif
if (doreopen) {
doreopen = false;
-@@ -938,7 +932,7 @@ static int child(arg_data *args, home_data *data, uid_
+@@ -969,7 +964,7 @@ static int child(arg_data *args, home_data *data, uid_
return 6;
if (doreload == true)
@@ -52,7 +88,7 @@
else
ret = 0;
-@@ -1348,10 +1342,10 @@ static int run_controller(arg_data *args, home_data *d
+@@ -1385,10 +1380,10 @@ static int run_controller(arg_data *args, home_data *d
if (args->vers != true && args->chck != true && status != 122)
remove_pid_file(args, pid);
@@ -65,7 +101,7 @@
if (args->restarts == 0) {
log_debug("Service failure, restarts disabled");
return 1;
-@@ -1363,7 +1357,7 @@ static int run_controller(arg_data *args, home_data *d
+@@ -1400,7 +1395,7 @@ static int run_controller(arg_data *args, home_data *d
log_debug("Reloading service");
restarts++;
/* prevent looping */