summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnas Nashif <anas.nashif@intel.com>2012-11-10 07:08:08 -0800
committerAnas Nashif <anas.nashif@intel.com>2012-11-10 07:08:08 -0800
commit3f36a809de678457b68a87f225d3fc86aeb804e5 (patch)
treee0f4a49f7c3e3556b0d68b8ac117fc45429c56f4
parentdfe6a216e0d5eaff3f16607190eaef2f7058aef8 (diff)
downloadxinit-3f36a809de678457b68a87f225d3fc86aeb804e5.tar.gz
xinit-3f36a809de678457b68a87f225d3fc86aeb804e5.tar.bz2
xinit-3f36a809de678457b68a87f225d3fc86aeb804e5.zip
client session
-rw-r--r--xinit.c15
1 files changed, 14 insertions, 1 deletions
diff --git a/xinit.c b/xinit.c
index 2ab817f..51625e6 100644
--- a/xinit.c
+++ b/xinit.c
@@ -89,6 +89,7 @@ char xserverrcbuf[256];
#define TRUE 1
#define FALSE 0
+#define ERR_EXIT 1
static char *default_server = "X";
static char *default_display = ":0"; /* choose most efficient */
@@ -559,6 +560,8 @@ startClient(char *client[])
{
clientpid = fork();
if (clientpid == 0) {
+ int fd;
+
set_environment();
setWindowPath();
@@ -566,7 +569,17 @@ startClient(char *client[])
Error("cannot change uid");
_exit(EXIT_FAILURE);
}
- setpgid(0, getpid());
+
+ fd = open ("/dev/null", O_RDONLY);
+ if (fd < 0) {
+ Error("cannot open /dev/null: %s\n", strerror(errno));
+ _exit(ERR_EXIT);
+ }
+ close (STDIN_FILENO);
+ dup2 (fd, STDIN_FILENO);
+ close (fd);
+ setsid();
+
Execute(client);
Error("Unable to run program \"%s\"", client[0]);