2 #include <sys/socket.h>
9 #include <libubox/usock.h>
13 static struct uloop_fd server_fd
;
14 static char *socket_name
;
17 static void server_fd_cb(struct uloop_fd
*ufd
, unsigned int events
)
21 int fd
= accept(ufd
->fd
, NULL
, 0);
23 if (errno
== EINTR
|| errno
== ECONNABORTED
)
32 static int usage(const char *progname
)
34 fprintf(stderr
, "Usage: %s [options]\n"
36 " -s <name>: Set path to socket\n"
41 static void mkdir_sockdir(void)
45 sep
= strrchr(socket_name
, '/');
50 mkdir(socket_name
, 0755);
54 int main(int argc
, char **argv
)
59 while ((ch
= getopt(argc
, argv
, "s:")) != -1) {
65 return usage(argv
[0]);
70 socket_name
= strdup(UDEBUG_SOCK_NAME
);
72 signal(SIGPIPE
, SIG_IGN
);
79 server_fd
.cb
= server_fd_cb
;
80 server_fd
.fd
= usock(USOCK_UNIX
| USOCK_SERVER
| USOCK_NONBLOCK
, socket_name
, NULL
);
81 if (server_fd
.fd
< 0) {
86 uloop_fd_add(&server_fd
, ULOOP_READ
);