mirror of
https://github.com/Telecominfraproject/wlan-ap.git
synced 2025-12-19 02:11:28 +00:00
This series is based on * 2020-07-10 ipq6018-ilq-11-0_qca_oem-034672b0676c37b1f4519e5720e18e95fe6236ef Add support for * qsdk kernel/v4.4 * qsdk ethernet subsystem * v5.7 ath11k backport + QualComm staging patches (wlan_ap_1.0) * ath11k-firmware * hostapd/iw/... Feature support * full boot, system detection * sysupgrade to nand * HE support via latest hostapd * driver support for usb, crypto, hwmon, cpufreq, ... Missing * NSS/HW flow offloading - FW blob is not redistributable Using the qsdk v4.4 is an intermediate solution while the vanilla is being tested. Vanilla kernel is almost on feature par. Work has already started to upstream the ethernet and switch drivers. Once complete the target will be fully upstream. Signed-off-by: John Crispin <john@phrozen.org>
98 lines
1.8 KiB
Diff
98 lines
1.8 KiB
Diff
--- a/src/utils/os_unix.c
|
|
+++ b/src/utils/os_unix.c
|
|
@@ -10,6 +10,7 @@
|
|
|
|
#include <time.h>
|
|
#include <sys/wait.h>
|
|
+#include <fcntl.h>
|
|
|
|
#ifdef ANDROID
|
|
#include <sys/capability.h>
|
|
@@ -188,59 +189,46 @@ int os_gmtime(os_time_t t, struct os_tm
|
|
return 0;
|
|
}
|
|
|
|
-
|
|
-#ifdef __APPLE__
|
|
-#include <fcntl.h>
|
|
-static int os_daemon(int nochdir, int noclose)
|
|
+int os_daemonize(const char *pid_file)
|
|
{
|
|
- int devnull;
|
|
+ int pid = 0, i, devnull;
|
|
|
|
- if (chdir("/") < 0)
|
|
- return -1;
|
|
+#if defined(__uClinux__) || defined(__sun__)
|
|
+ return -1;
|
|
+#else /* defined(__uClinux__) || defined(__sun__) */
|
|
|
|
- devnull = open("/dev/null", O_RDWR);
|
|
- if (devnull < 0)
|
|
+#ifndef __APPLE__
|
|
+ pid = fork();
|
|
+ if (pid < 0)
|
|
return -1;
|
|
+#endif
|
|
|
|
- if (dup2(devnull, STDIN_FILENO) < 0) {
|
|
- close(devnull);
|
|
- return -1;
|
|
+ if (pid > 0) {
|
|
+ if (pid_file) {
|
|
+ FILE *f = fopen(pid_file, "w");
|
|
+ if (f) {
|
|
+ fprintf(f, "%u\n", pid);
|
|
+ fclose(f);
|
|
+ }
|
|
+ }
|
|
+ _exit(0);
|
|
}
|
|
|
|
- if (dup2(devnull, STDOUT_FILENO) < 0) {
|
|
- close(devnull);
|
|
+ if (setsid() < 0)
|
|
return -1;
|
|
- }
|
|
|
|
- if (dup2(devnull, STDERR_FILENO) < 0) {
|
|
- close(devnull);
|
|
+ if (chdir("/") < 0)
|
|
return -1;
|
|
- }
|
|
-
|
|
- return 0;
|
|
-}
|
|
-#else /* __APPLE__ */
|
|
-#define os_daemon daemon
|
|
-#endif /* __APPLE__ */
|
|
|
|
-
|
|
-int os_daemonize(const char *pid_file)
|
|
-{
|
|
-#if defined(__uClinux__) || defined(__sun__)
|
|
- return -1;
|
|
-#else /* defined(__uClinux__) || defined(__sun__) */
|
|
- if (os_daemon(0, 0)) {
|
|
- perror("daemon");
|
|
+ devnull = open("/dev/null", O_RDWR);
|
|
+ if (devnull < 0)
|
|
return -1;
|
|
- }
|
|
|
|
- if (pid_file) {
|
|
- FILE *f = fopen(pid_file, "w");
|
|
- if (f) {
|
|
- fprintf(f, "%u\n", getpid());
|
|
- fclose(f);
|
|
- }
|
|
- }
|
|
+ for (i = 0; i <= STDERR_FILENO; i++)
|
|
+ dup2(devnull, i);
|
|
+
|
|
+ if (devnull > 2)
|
|
+ close(devnull);
|
|
|
|
return -0;
|
|
#endif /* defined(__uClinux__) || defined(__sun__) */
|