VirtualBox

Ignore:
Timestamp:
Jan 15, 2008 1:27:51 PM (17 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
27270
Message:

Integrated VbglR3Daemonize in GuestR3Lib. Linux vboxclient now uses it. Renamed LINUX_CLIPBOARD to VBOX_X11_CLIPBOARD. clipboard-new has the clipboard implemetation using R3 lib, currently used only by Solaris. Note: this change affects OS2, linux, solaris so someone should check for build breaks on OS2.

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  
    1919include $(PATH_KBUILD)/header.kmk
    2020
     21if1of ($(BUILD_TARGET),linux l4)
    2122ifneq ($(USERNAME),bird) # crap
    2223 PROGRAMS = vboxadd-xclient
     
    2728vboxadd-xclient_TEMPLATE = VBOXLNX32GUESTR3EXE
    2829vboxadd-xclient_SOURCES  = clipboard.cpp main.cpp
    29 vboxadd-xclient_DEFS    += CLIPBOARD_LINUX
     30vboxadd-xclient_DEFS    += VBOX_X11_CLIPBOARD
    3031
    3132ifdef LINUX_SEAMLESS_GUEST
     
    7879 endif
    7980endif
     81endif # target linux l4
     82
     83ifeq ($(BUILD_TARGET),solaris)
     84PROGRAMS = VBoxClient
     85
     86VBoxClient_TEMPLATE = VBOXGUESTR3EXE
     87VBoxClient_DEFS    += VBOX_X11_CLIPBOARD VBOX_HGCM
     88VBoxClient_SOURCES  = \
     89        clipboard-new.cpp \
     90        main.cpp
     91VBoxClient_LIBS = \
     92        $(VBOX_LIB_VBGL_R3) \
     93        $(VBOX_LIB_IPRT_GUEST_R3) \
     94        X11 \
     95        Xt
     96endif # target solaris
    8097
    8198include $(PATH_KBUILD)/footer.kmk
  • TabularUnified trunk/src/VBox/Additions/x11/xclient/main.cpp

    r6290 r6356  
    2626
    2727#include <sys/types.h>
    28 #include <sys/stat.h>     /* For umask */
    29 #include <fcntl.h>        /* For open */
    3028#include <stdlib.h>       /* For exit */
    3129#include <unistd.h>
    3230#include <getopt.h>
    33 
    34 #include <sys/time.h>     /* For getrlimit */
    35 #include <sys/resource.h> /* For getrlimit */
    3631
    3732#include <X11/Xlib.h>
     
    4540
    4641static 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 let
    57        the parent process exit, as a newly created child is never session leader.  This will
    58        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 three
    67            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 receiving
    83        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 }
    9142
    9243/**
     
    11061        return 0;
    11162    }
    112 #ifdef CLIPBOARD_LINUX
     63#ifdef VBOX_X11_CLIPBOARD
    11364    vboxClipboardDisconnect();
    11465#endif
     
    157108        }
    158109    }
     110    gbDaemonise = false; // ram
    159111    if (gbDaemonise)
    160112    {
    161         vboxDaemonise();
     113        if (VbglR3Daemonize(0, 0) != 0)
     114        {
     115            LogRel(("VBoxService: failed to daemonize. exiting."));
     116            return 1;
     117        }
    162118    }
    163119    /* Initialise our runtime before all else. */
     
    178134    /* Set an X11 error handler, so that we don't die when we get unavoidable errors. */
    179135    XSetErrorHandler(vboxClientXLibErrorHandler);
    180 #ifdef CLIPBOARD_LINUX
     136#ifdef VBOX_X11_CLIPBOARD
    181137    /* Connect to the host clipboard. */
    182138    LogRel(("VBoxService: starting clipboard Guest Additions...\n"));
     
    186142        LogRel(("VBoxService: vboxClipboardConnect failed with rc = %Rrc\n", rc));
    187143    }
    188 #endif  /* CLIPBOARD_LINUX defined */
     144#endif  /* VBOX_X11_CLIPBOARD defined */
    189145#ifdef SEAMLESS_LINUX
    190146    try
     
    208164    }
    209165#endif /* SEAMLESS_LINUX defined */
    210 #ifdef CLIPBOARD_LINUX
     166#ifdef VBOX_X11_CLIPBOARD
    211167    LogRel(("VBoxService: connecting to the shared clipboard service.\n"));
    212168    vboxClipboardMain();
    213169    vboxClipboardDisconnect();
    214 #else  /* CLIPBOARD_LINUX not defined */
     170#else  /* VBOX_X11_CLIPBOARD not defined */
    215171    LogRel(("VBoxService: sleeping...\n"));
    216172    pause();
    217173    LogRel(("VBoxService: exiting...\n"));
    218 #endif  /* CLIPBOARD_LINUX not defined */
     174#endif  /* VBOX_X11_CLIPBOARD not defined */
    219175#ifdef SEAMLESS_LINUX
    220176    try
Note: See TracChangeset for help on using the changeset viewer.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette