[Pcsclite-cvs-commit] r1693 - trunk/PCSC/src

Ludovic Rousseau rousseau at costa.debian.org
Fri Oct 21 08:01:39 UTC 2005


Author: rousseau
Date: 2005-10-21 08:01:38 +0000 (Fri, 21 Oct 2005)
New Revision: 1693

Modified:
   trunk/PCSC/src/sys_unix.c
Log:
SYS_Daemon(): manually detatch from terminal on Solaris in case
daemon(3) does not exist


Modified: trunk/PCSC/src/sys_unix.c
===================================================================
--- trunk/PCSC/src/sys_unix.c	2005-10-19 08:11:32 UTC (rev 1692)
+++ trunk/PCSC/src/sys_unix.c	2005-10-21 08:01:38 UTC (rev 1693)
@@ -386,6 +386,38 @@
 #ifdef HAVE_DAEMON
 	return daemon(nochdir, noclose);
 #else
+
+#if defined(__SVR4) && defined(__sun)
+	pid_t pid;
+
+	pid = SYS_Fork();
+	if (-1 == pid)
+	{
+		Log2(PCSC_LOG_CRITICAL, "main: SYS_Fork() failed: %s", strerror(errno));
+		return -1;
+	}
+	else
+	{
+		if (pid != 0)
+			/* the father exits */
+			exit(0);
+	}
+	
+	setsid();
+
+	pid = SYS_Fork();
+	if (-1 == pid)
+	{
+		Log2(PCSC_LOG_CRITICAL, "main: SYS_Fork() failed: %s", strerror(errno));
+		exit(1);
+	}
+	else
+	{
+		if (pid != 0)
+			/* the father exits */
+			exit(0);
+	}
+#else
 	switch (SYS_Fork())
 	{
 	case -1:
@@ -395,6 +427,7 @@
 	default:
 		return (0);
 	}
+#endif
 
 	if (!noclose) {
 		if (SYS_CloseFile(0))




More information about the Pcsclite-cvs-commit mailing list