Fix error handling in -c option
git-svn-id: https://yap.svn.sf.net/svnroot/yap/trunk@834 b08c6af1-5177-4d33-ba66-4b1c6b8b522a
This commit is contained in:
parent
0eb0f6c3d0
commit
f3914ac22e
20
C/ypsocks.c
20
C/ypsocks.c
@ -230,51 +230,51 @@ Yap_init_socks(char *host, long interface_port)
|
|||||||
|
|
||||||
r = connect ( s, (struct sockaddr *) &soadr, sizeof(soadr));
|
r = connect ( s, (struct sockaddr *) &soadr, sizeof(soadr));
|
||||||
if (r<0) {
|
if (r<0) {
|
||||||
fprintf(Yap_stderr,"connect failed with %d\n",r);
|
fprintf(stderr,"connect failed with %d\n",r);
|
||||||
crash("[ could not connect to interface]");
|
crash("[ could not connect to interface]");
|
||||||
}
|
}
|
||||||
/* now reopen stdin stdout and stderr */
|
/* now reopen stdin stdout and stderr */
|
||||||
#if HAVE_DUP2 && !defined(__MINGW32__)
|
#if HAVE_DUP2 && !defined(__MINGW32__)
|
||||||
if(dup2(s,0)<0) {
|
if(dup2(s,0)<0) {
|
||||||
fprintf(Yap_stderr,"could not dup2 stdin\n");
|
fprintf(stderr,"could not dup2 stdin\n");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if(dup2(s,1)<0) {
|
if(dup2(s,1)<0) {
|
||||||
fprintf(Yap_stderr,"could not dup2 stdout\n");
|
fprintf(stderr,"could not dup2 stdout\n");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if(dup2(s,2)<0) {
|
if(dup2(s,2)<0) {
|
||||||
fprintf(Yap_stderr,"could not dup2 stderr\n");
|
fprintf(stderr,"could not dup2 stderr\n");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
#elif _MSC_VER || defined(__MINGW32__)
|
#elif _MSC_VER || defined(__MINGW32__)
|
||||||
if(_dup2(s,0)<0) {
|
if(_dup2(s,0)<0) {
|
||||||
fprintf(Yap_stderr,"could not dup2 stdin\n");
|
fprintf(stderr,"could not dup2 stdin\n");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if(_dup2(s,1)<0) {
|
if(_dup2(s,1)<0) {
|
||||||
fprintf(Yap_stderr,"could not dup2 stdout\n");
|
fprintf(stderr,"could not dup2 stdout\n");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if(_dup2(s,2)<0) {
|
if(_dup2(s,2)<0) {
|
||||||
fprintf(Yap_stderr,"could not dup2 stderr\n");
|
fprintf(stderr,"could not dup2 stderr\n");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
if(dup2(s,0)<0) {
|
if(dup2(s,0)<0) {
|
||||||
fprintf(Yap_stderr,"could not dup2 stdin\n");
|
fprintf(stderr,"could not dup2 stdin\n");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
yp_iob[0].cnt = 0;
|
yp_iob[0].cnt = 0;
|
||||||
yp_iob[0].flags = _YP_IO_SOCK | _YP_IO_READ;
|
yp_iob[0].flags = _YP_IO_SOCK | _YP_IO_READ;
|
||||||
if(dup2(s,1)<0) {
|
if(dup2(s,1)<0) {
|
||||||
fprintf(Yap_stderr,"could not dup2 stdout\n");
|
fprintf(stderr,"could not dup2 stdout\n");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
yp_iob[1].cnt = 0;
|
yp_iob[1].cnt = 0;
|
||||||
yp_iob[1].flags = _YP_IO_SOCK | _YP_IO_WRITE;
|
yp_iob[1].flags = _YP_IO_SOCK | _YP_IO_WRITE;
|
||||||
if(dup2(s,2)<0) {
|
if(dup2(s,2)<0) {
|
||||||
fprintf(Yap_stderr,"could not dup2 stderr\n");
|
fprintf(stderr,"could not dup2 stderr\n");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
yp_iob[2].cnt = 0;
|
yp_iob[2].cnt = 0;
|
||||||
|
Reference in New Issue
Block a user