struct epoll_event epev;
fprintf(MSG_OUT, "Creating named pipe \"%s\"\n", fifo);
- if(lstat (fifo, &st) == 0) {
+ if(lstat(fifo, &st) == 0) {
if((st.st_mode & S_IFMT) == S_IFREG) {
errno = EEXIST;
perror("lstat");
- exit(1);
+ return 1;
}
}
unlink(fifo);
- if(mkfifo (fifo, 0600) == -1) {
+ if(mkfifo(fifo, 0600) == -1) {
perror("mkfifo");
- exit(1);
+ return 1;
}
sockfd = open(fifo, O_RDWR | O_NONBLOCK, 0);
if(sockfd == -1) {
perror("open");
- exit(1);
+ return 1;
}
g->fifofd = sockfd;
static void clean_fifo(GlobalInfo *g)
{
- epoll_ctl(g->epfd, EPOLL_CTL_DEL, g->fifofd, NULL);
- fclose(g->input);
- unlink(fifo);
+ epoll_ctl(g->epfd, EPOLL_CTL_DEL, g->fifofd, NULL);
+ fclose(g->input);
+ unlink(fifo);
}
g.epfd = epoll_create1(EPOLL_CLOEXEC);
if(g.epfd == -1) {
perror("epoll_create1 failed");
- exit(1);
+ return 1;
}
g.tfd = timerfd_create(CLOCK_MONOTONIC, TFD_NONBLOCK | TFD_CLOEXEC);
if(g.tfd == -1) {
perror("timerfd_create failed");
- exit(1);
+ return 1;
}
memset(&its, 0, sizeof(struct itimerspec));
ev.data.fd = g.tfd;
epoll_ctl(g.epfd, EPOLL_CTL_ADD, g.tfd, &ev);
- init_fifo(&g);
+ if(init_fifo(&g))
+ return 1;
g.multi = curl_multi_init();
/* setup the generic multi interface options we want */
}
else {
perror("epoll_wait");
- exit(1);
+ return 1;
}
}
curl_socket_t sockfd;
fprintf(MSG_OUT, "Creating named pipe \"%s\"\n", fifo);
- if(lstat (fifo, &st) == 0) {
+ if(lstat(fifo, &st) == 0) {
if((st.st_mode & S_IFMT) == S_IFREG) {
errno = EEXIST;
perror("lstat");
- exit(1);
+ return 1;
}
}
unlink(fifo);
- if(mkfifo (fifo, 0600) == -1) {
+ if(mkfifo(fifo, 0600) == -1) {
perror("mkfifo");
- exit(1);
+ return 1;
}
sockfd = open(fifo, O_RDWR | O_NONBLOCK, 0);
if(sockfd == -1) {
perror("open");
- exit(1);
+ return 1;
}
g->input = fdopen(sockfd, "r");
memset(&g, 0, sizeof(GlobalInfo));
g.loop = ev_default_loop(0);
- init_fifo(&g);
+ if(init_fifo(&g))
+ return 1;
g.multi = curl_multi_init();
ev_timer_init(&g.timer_event, timer_cb, 0., 0.);
if((st.st_mode & S_IFMT) == S_IFREG) {
errno = EEXIST;
perror("lstat");
- exit(1);
+ return CURL_SOCKET_BAD;
}
}
unlink(fifo);
- if(mkfifo (fifo, 0600) == -1) {
+ if(mkfifo(fifo, 0600) == -1) {
perror("mkfifo");
- exit(1);
+ return CURL_SOCKET_BAD;
}
socket = open(fifo, O_RDWR | O_NONBLOCK, 0);
- if(socket == -1) {
+ if(socket == CURL_SOCKET_BAD) {
perror("open");
- exit(1);
+ return socket;
}
MSG_OUT("Now, pipe some URL's into > %s\n", fifo);
GIOChannel* ch;
fd = init_fifo();
+ if(fd == CURL_SOCKET_BAD)
+ return 1;
ch = g_io_channel_unix_new(fd);
g_io_add_watch(ch, G_IO_IN, fifo_cb, g);
gmain = g_main_loop_new(NULL, FALSE);
curl_socket_t sockfd;
fprintf(MSG_OUT, "Creating named pipe \"%s\"\n", fifo);
- if(lstat (fifo, &st) == 0) {
+ if(lstat(fifo, &st) == 0) {
if((st.st_mode & S_IFMT) == S_IFREG) {
errno = EEXIST;
perror("lstat");
- exit(1);
+ return 1;
}
}
unlink(fifo);
if(mkfifo (fifo, 0600) == -1) {
perror("mkfifo");
- exit(1);
+ return 1;
}
sockfd = open(fifo, O_RDWR | O_NONBLOCK, 0);
if(sockfd == -1) {
perror("open");
- exit(1);
+ return 1;
}
g->input = fdopen(sockfd, "r");
memset(&g, 0, sizeof(GlobalInfo));
g.evbase = event_base_new();
- init_fifo(&g);
+ if(init_fifo(&g))
+ return 1;
g.multi = curl_multi_init();
evtimer_assign(&g.timer_event, g.evbase, timer_cb, &g);