]> andersk Git - moira.git/blobdiff - gdb/gdb.c
solaris won't compile with variable named "uname"
[moira.git] / gdb / gdb.c
index 3eeebf8ce9917efd6624fa4e2f5baa200f7ea988..03d10ee59682e44aa868f001007ab08f869ff5f1 100644 (file)
--- a/gdb/gdb.c
+++ b/gdb/gdb.c
@@ -34,6 +34,9 @@ static char *rcsid_gdb_c = "$Header$";
 #include "gdb.h"
 #include "gdb_lib.h"
 #include <errno.h>
+#ifdef POSIX
+#include <sys/utsname.h>
+#endif
 
 extern int sys_nerr;
 extern char *sys_errlist[];
@@ -65,10 +68,18 @@ gdb_init()
        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
         */
@@ -96,11 +107,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
@@ -112,13 +121,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);
 
@@ -128,11 +147,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;
 }
This page took 0.035687 seconds and 4 git commands to generate.