Changeset 6356 in vbox for trunk/src/VBox/Additions/x11/xclient
- Timestamp:
- Jan 15, 2008 1:27:51 PM (17 years ago)
- svn:sync-xref-src-repo-rev:
- 27270
- Location:
- trunk/src/VBox/Additions/x11/xclient
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
TabularUnified trunk/src/VBox/Additions/x11/xclient/Makefile.kmk ¶
r6290 r6356 19 19 include $(PATH_KBUILD)/header.kmk 20 20 21 if1of ($(BUILD_TARGET),linux l4) 21 22 ifneq ($(USERNAME),bird) # crap 22 23 PROGRAMS = vboxadd-xclient … … 27 28 vboxadd-xclient_TEMPLATE = VBOXLNX32GUESTR3EXE 28 29 vboxadd-xclient_SOURCES = clipboard.cpp main.cpp 29 vboxadd-xclient_DEFS += CLIPBOARD_LINUX30 vboxadd-xclient_DEFS += VBOX_X11_CLIPBOARD 30 31 31 32 ifdef LINUX_SEAMLESS_GUEST … … 78 79 endif 79 80 endif 81 endif # target linux l4 82 83 ifeq ($(BUILD_TARGET),solaris) 84 PROGRAMS = VBoxClient 85 86 VBoxClient_TEMPLATE = VBOXGUESTR3EXE 87 VBoxClient_DEFS += VBOX_X11_CLIPBOARD VBOX_HGCM 88 VBoxClient_SOURCES = \ 89 clipboard-new.cpp \ 90 main.cpp 91 VBoxClient_LIBS = \ 92 $(VBOX_LIB_VBGL_R3) \ 93 $(VBOX_LIB_IPRT_GUEST_R3) \ 94 X11 \ 95 Xt 96 endif # target solaris 80 97 81 98 include $(PATH_KBUILD)/footer.kmk -
TabularUnified trunk/src/VBox/Additions/x11/xclient/main.cpp ¶
r6290 r6356 26 26 27 27 #include <sys/types.h> 28 #include <sys/stat.h> /* For umask */29 #include <fcntl.h> /* For open */30 28 #include <stdlib.h> /* For exit */ 31 29 #include <unistd.h> 32 30 #include <getopt.h> 33 34 #include <sys/time.h> /* For getrlimit */35 #include <sys/resource.h> /* For getrlimit */36 31 37 32 #include <X11/Xlib.h> … … 45 40 46 41 static bool gbDaemonise = true; 47 48 /**49 * Go through the long Un*x ritual required to become a daemon process.50 */51 void vboxDaemonise(void)52 {53 /** rlimit structure for finding out how many open files we may have. */54 struct rlimit rlim;55 56 /* To make sure that we are not currently a session leader, we must first fork and let57 the parent process exit, as a newly created child is never session leader. This will58 allow us to call setsid() later. */59 if (fork() != 0)60 {61 exit(0);62 }63 /* Find the maximum number of files we can have open and close them all. */64 if (0 != getrlimit(RLIMIT_NOFILE, &rlim))65 {66 /* For some reason the call failed. In that case we will just close the three67 standard files and hope. */68 rlim.rlim_cur = 3;69 }70 for (unsigned int i = 0; i < rlim.rlim_cur; ++i)71 {72 close(i);73 }74 /* Change to the root directory to avoid keeping the one we were started in open. */75 chdir("/");76 /* Set our umask to zero. */77 umask(0);78 /* And open /dev/null on stdin/out/err. */79 open("/dev/null", O_RDONLY);80 open("/dev/null", O_WRONLY);81 dup(1);82 /* Detach from the controlling terminal by creating our own session, to avoid receiving83 signals from the old session. */84 setsid();85 /* And fork again, letting the parent exit, to make us a child of init and avoid zombies. */86 if (fork() != 0)87 {88 exit(0);89 }90 }91 42 92 43 /** … … 110 61 return 0; 111 62 } 112 #ifdef CLIPBOARD_LINUX63 #ifdef VBOX_X11_CLIPBOARD 113 64 vboxClipboardDisconnect(); 114 65 #endif … … 157 108 } 158 109 } 110 gbDaemonise = false; // ram 159 111 if (gbDaemonise) 160 112 { 161 vboxDaemonise(); 113 if (VbglR3Daemonize(0, 0) != 0) 114 { 115 LogRel(("VBoxService: failed to daemonize. exiting.")); 116 return 1; 117 } 162 118 } 163 119 /* Initialise our runtime before all else. */ … … 178 134 /* Set an X11 error handler, so that we don't die when we get unavoidable errors. */ 179 135 XSetErrorHandler(vboxClientXLibErrorHandler); 180 #ifdef CLIPBOARD_LINUX136 #ifdef VBOX_X11_CLIPBOARD 181 137 /* Connect to the host clipboard. */ 182 138 LogRel(("VBoxService: starting clipboard Guest Additions...\n")); … … 186 142 LogRel(("VBoxService: vboxClipboardConnect failed with rc = %Rrc\n", rc)); 187 143 } 188 #endif /* CLIPBOARD_LINUXdefined */144 #endif /* VBOX_X11_CLIPBOARD defined */ 189 145 #ifdef SEAMLESS_LINUX 190 146 try … … 208 164 } 209 165 #endif /* SEAMLESS_LINUX defined */ 210 #ifdef CLIPBOARD_LINUX166 #ifdef VBOX_X11_CLIPBOARD 211 167 LogRel(("VBoxService: connecting to the shared clipboard service.\n")); 212 168 vboxClipboardMain(); 213 169 vboxClipboardDisconnect(); 214 #else /* CLIPBOARD_LINUXnot defined */170 #else /* VBOX_X11_CLIPBOARD not defined */ 215 171 LogRel(("VBoxService: sleeping...\n")); 216 172 pause(); 217 173 LogRel(("VBoxService: exiting...\n")); 218 #endif /* CLIPBOARD_LINUXnot defined */174 #endif /* VBOX_X11_CLIPBOARD not defined */ 219 175 #ifdef SEAMLESS_LINUX 220 176 try
Note:
See TracChangeset
for help on using the changeset viewer.