#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[];
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 */
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
*/
*/
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
* 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);
uname = pw_struct->pw_name;
else
uname = "????";
- gdb_uname = db_alloc(strlen(hostname)+1);
+ gdb_uname = db_alloc(strlen(uname)+1);
(void) strcpy(gdb_uname, uname);
return 0;