]> andersk Git - moira.git/blobdiff - gdb/gdb.c
don't flame about being unable to delete filesystem if the `propagate
[moira.git] / gdb / gdb.c
index b3237239636d51fb580acf16bf8de47c3209a1c5..27c62b202f83d6874e28227ab650b659bd489754 100644 (file)
--- a/gdb/gdb.c
+++ b/gdb/gdb.c
@@ -5,7 +5,7 @@
 
 #ifndef lint
 static char *rcsid_gdb_c = "$Header$";
-#endif lint
+#endif
 
 
 /************************************************************************/
@@ -28,18 +28,28 @@ static char *rcsid_gdb_c = "$Header$";
 /************************************************************************/
 
 #include <stdio.h>
-#include <strings.h>
+#include <string.h>
 #include <signal.h> 
 #include <pwd.h>
 #include "gdb.h"
 #include "gdb_lib.h"
 #include <errno.h>
+#ifdef POSIX
+#include <sys/utsname.h>
+#include <unistd.h>
+#endif
 
+#ifndef __NetBSD__
 extern int sys_nerr;
 extern char *sys_errlist[];
+#endif
 
 extern int errno;
 
+/* This global is defined to make sure that Moira clients are linked
+ * against the correct library.
+ */
+int link_against_the_moira_version_of_gdb = 0;
 int g_inited = FALSE;                          /* gdb_init has not been */
                                                /* called */
 
@@ -59,12 +69,19 @@ gdb_init()
 {
        register int i;
        char hostname[255];                     /* name of local host */
-       extern uid_t getuid();
        int uid;                                /* Unix user-i.d. number */
-       char *uname;                            /* string form of i.d. */
+       char *username;                         /* string form of i.d. */
 
        struct passwd *pw_struct;               /* passwd entry comes back */
                                                /* here */
+#ifdef POSIX
+       struct utsname nameposix;
+       struct sigaction act;
+
+       sigemptyset(&act.sa_mask);
+       act.sa_flags = 0;
+#endif
+
        /*
         * So we know we've been initialized, and we do it only once
         */
@@ -92,11 +109,9 @@ gdb_init()
         */
        gdb_mfd = 0;
 
-       for (i=0; i<NFDBITS/sizeof(int); i++) {
-               gdb_crfds.fds_bits[i] = 0;
-               gdb_cwfds.fds_bits[i] = 0;
-               gdb_cefds.fds_bits[i] = 0;
-       }
+       FD_ZERO(&gdb_crfds);
+       FD_ZERO(&gdb_cwfds);
+       FD_ZERO(&gdb_cefds);
 
        /*
         * Initialize the server/client layer
@@ -108,13 +123,23 @@ gdb_init()
         * closed at the other end.  gdb_move_data handles this condition
         * synchronously.
         */
+#ifdef POSIX
+       act.sa_handler = (void(*)()) SIG_IGN;
+       (void) sigaction(SIGPIPE, &act, NULL);
+#else
        (void) signal(SIGPIPE, SIG_IGN);
+#endif
 
        /*
         * Make a note of the local host and user name
         */
+#ifdef POSIX
+       (void) uname(&nameposix);
+       strncpy(hostname, nameposix.nodename, sizeof(hostname) - 1);
+#else
        if (gethostname(hostname, sizeof(hostname)-1)!=0)
                (void) strcpy(hostname, "????");
+#endif
        gdb_host = db_alloc(strlen(hostname)+1);
        (void) strcpy(gdb_host, hostname);
 
@@ -124,11 +149,11 @@ gdb_init()
 
        if (pw_struct != NULL && pw_struct ->pw_name != NULL &&
            *pw_struct->pw_name !='\0') 
-               uname = pw_struct->pw_name;
+               username = pw_struct->pw_name;
        else
-               uname = "????";
-       gdb_uname = db_alloc(strlen(uname)+1);
-       (void) strcpy(gdb_uname, uname);        
+               username = "????";
+       gdb_uname = db_alloc(strlen(username)+1);
+       (void) strcpy(gdb_uname, username);     
        
        return 0;
 }
@@ -244,6 +269,6 @@ char *msg;
        if(errno < sys_nerr)
                fprintf(gdb_log, "%s.\n", sys_errlist[errno]);
        else
-               fprintf(gdb_log, "errno %d is out of range of message table.\n");
+               fprintf(gdb_log, "errno %d is out of range of message table.\n", errno);
 }
 
This page took 0.039451 seconds and 4 git commands to generate.