/*
- * "$Id: process.c 5094 2006-02-09 01:00:26Z mike $"
+ * "$Id: process.c 6326 2007-03-11 17:50:18Z mike $"
*
* Process management routines for the Common UNIX Printing System (CUPS).
*
- * Copyright 1997-2006 by Easy Software Products, all rights reserved.
+ * Copyright 1997-2007 by Easy Software Products, all rights reserved.
*
* These coded instructions, statements, and computer programs are the
* property of Easy Software Products and are protected by Federal
#include "cupsd.h"
#include <grp.h>
-#if defined(__APPLE__) && __GNUC__ < 4
+#if defined(__APPLE__)
# include <libgen.h>
-#endif /* __APPLE__ && __GNUC__ < 4 */
+#endif /* __APPLE__ */
/*
int outfd, /* I - Standard output file descriptor */
int errfd, /* I - Standard error file descriptor */
int backfd, /* I - Backchannel file descriptor */
+ int sidefd, /* I - Sidechannel file descriptor */
int root, /* I - Run as root? */
int *pid) /* O - Process ID */
{
#if defined(HAVE_SIGACTION) && !defined(HAVE_SIGSET)
struct sigaction action; /* POSIX signal handler */
#endif /* HAVE_SIGACTION && !HAVE_SIGSET */
-#if defined(__APPLE__) && __GNUC__ < 4
- int envc; /* Number of environment variables */
+#if defined(__APPLE__)
char processPath[1024], /* CFProcessPath environment variable */
linkpath[1024]; /* Link path for symlinks... */
int linkbytes; /* Bytes for link path */
-#endif /* __APPLE__ && __GNUC__ < 4 */
+#endif /* __APPLE__ */
cupsdLogMessage(CUPSD_LOG_DEBUG2,
"cupsdStartProcess(\"%s\", %p, %p, %d, %d, %d)",
command, argv, envp, infd, outfd, errfd);
-#if defined(__APPLE__) && __GNUC__ < 4
- /*
- * Add special voodoo magic for MacOS X 10.3 and earlier - this allows
- * MacOS X programs to access their bundle resources properly...
- */
-
- if ((linkbytes = readlink(command, linkpath, sizeof(linkpath) - 1)) > 0)
+#if defined(__APPLE__)
+ if (envp)
{
/*
- * Yes, this is a symlink to the actual program, nul-terminate and
- * use it...
+ * Add special voodoo magic for MacOS X - this allows MacOS X
+ * programs to access their bundle resources properly...
*/
- linkpath[linkbytes] = '\0';
+ if ((linkbytes = readlink(command, linkpath, sizeof(linkpath) - 1)) > 0)
+ {
+ /*
+ * Yes, this is a symlink to the actual program, nul-terminate and
+ * use it...
+ */
+
+ linkpath[linkbytes] = '\0';
- if (linkpath[0] == '/')
- snprintf(processPath, sizeof(processPath), "CFProcessPath=%s",
- linkpath);
+ if (linkpath[0] == '/')
+ snprintf(processPath, sizeof(processPath), "CFProcessPath=%s",
+ linkpath);
+ else
+ snprintf(processPath, sizeof(processPath), "CFProcessPath=%s/%s",
+ dirname((char *)command), linkpath);
+ }
else
- snprintf(processPath, sizeof(processPath), "CFProcessPath=%s/%s",
- dirname(command), linkpath);
- }
- else
- snprintf(processPath, sizeof(processPath), "CFProcessPath=%s", command);
+ snprintf(processPath, sizeof(processPath), "CFProcessPath=%s", command);
- envp[0] = processPath; /* Replace <CFProcessPath> string */
-#endif /* __APPLE__ && __GNUC__ > 3 */
+ envp[0] = processPath; /* Replace <CFProcessPath> string */
+ }
+#endif /* __APPLE__ */
/*
* Block signals before forking...
open("/dev/null", O_RDWR);
fcntl(3, F_SETFL, O_NDELAY);
}
+ if (sidefd != 4 && sidefd > 0)
+ {
+ close(4);
+ dup(sidefd);
+ fcntl(4, F_SETFL, O_NDELAY);
+ }
/*
* Change the priority of the process based on the FilterNice setting.
/*
- * End of "$Id: process.c 5094 2006-02-09 01:00:26Z mike $".
+ * End of "$Id: process.c 6326 2007-03-11 17:50:18Z mike $".
*/