2 #include <grass/config.h>
12 #include <sys/types.h>
14 #include <grass/gis.h>
22 connpath = G_sock_get_fname(me);
29 if (G_sock_exists(connpath)) {
30 if ((fd = G_sock_connect(connpath)) >= 0) {
32 G_warning(
"Graphics driver [%s] is already running", me);
36 if (unlink(connpath) < 0) {
37 G_warning(
"Failed to remove stale socket file: %s", connpath);
43 if ((fd = G_sock_bind(connpath)) < 0) {
49 if (G_sock_listen(fd, 1) != 0) {
50 G_fatal_error(
"G_sock_listen: error \"%s\"\n", strerror(errno));
65 FD_SET(listenfd, &waitset);
66 FD_SET(other_fd, &waitset);
67 if (select(FD_SETSIZE, &waitset,
NULL,
NULL,
NULL) < 0) {
68 perror(
"get_connection_sock: select");
72 if (!FD_ISSET(listenfd, &waitset))
78 fd = G_sock_accept(listenfd);
88 G_warning(
"G_sock_accept: error \"%s\"", strerror(errno));