mirror of
git://git.code.sf.net/p/zsh/code
synced 2025-10-25 17:20:25 +02:00
27286: Made movefd() return the targetfd on success. Added
a little more error checking in the callers of movefd().
This commit is contained in:
parent
51409732d0
commit
2f8aaaf5e4
4 changed files with 31 additions and 19 deletions
|
|
@ -1,3 +1,9 @@
|
||||||
|
2009-09-22 Wayne Davison <wayned@users.sourceforge.net>
|
||||||
|
|
||||||
|
* 27286: Src/Modules/socket.c Src/Modules/tcp.c Src/utils.c:
|
||||||
|
Made movefd() return the targetfd on success. Added a little
|
||||||
|
more error checking in the callers of movefd().
|
||||||
|
|
||||||
2009-09-22 Peter Stephenson <pws@csr.com>
|
2009-09-22 Peter Stephenson <pws@csr.com>
|
||||||
|
|
||||||
* 27284: Src/exec.c, Src/parse.c, Src/utils.c,
|
* 27284: Src/exec.c, Src/parse.c, Src/utils.c,
|
||||||
|
|
@ -12209,5 +12215,5 @@
|
||||||
|
|
||||||
*****************************************************
|
*****************************************************
|
||||||
* This is used by the shell to define $ZSH_PATCHLEVEL
|
* This is used by the shell to define $ZSH_PATCHLEVEL
|
||||||
* $Revision: 1.4786 $
|
* $Revision: 1.4787 $
|
||||||
*****************************************************
|
*****************************************************
|
||||||
|
|
|
||||||
|
|
@ -120,10 +120,7 @@ bin_zsocket(char *nam, char **args, Options ops, UNUSED(int func))
|
||||||
}
|
}
|
||||||
|
|
||||||
if (targetfd) {
|
if (targetfd) {
|
||||||
if (redup(sfd, targetfd) == -1)
|
sfd = redup(sfd, targetfd);
|
||||||
sfd = -1;
|
|
||||||
else
|
|
||||||
sfd = targetfd;
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
/* move the fd since no one will want to read from it */
|
/* move the fd since no one will want to read from it */
|
||||||
|
|
@ -205,8 +202,11 @@ bin_zsocket(char *nam, char **args, Options ops, UNUSED(int func))
|
||||||
}
|
}
|
||||||
|
|
||||||
if (targetfd) {
|
if (targetfd) {
|
||||||
redup(rfd, targetfd);
|
sfd = redup(rfd, targetfd);
|
||||||
sfd = targetfd;
|
if (sfd < 0) {
|
||||||
|
zerrnam(nam, "could not duplicate socket fd to %d: %e", targetfd, errno);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
sfd = rfd;
|
sfd = rfd;
|
||||||
|
|
@ -242,8 +242,11 @@ bin_zsocket(char *nam, char **args, Options ops, UNUSED(int func))
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (targetfd) {
|
if (targetfd) {
|
||||||
redup(sfd, targetfd);
|
sfd = redup(sfd, targetfd);
|
||||||
sfd = targetfd;
|
if (sfd < 0) {
|
||||||
|
zerrnam(nam, "could not duplicate socket fd to %d: %e", targetfd, errno);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
setiparam("REPLY", sfd);
|
setiparam("REPLY", sfd);
|
||||||
|
|
|
||||||
|
|
@ -446,10 +446,7 @@ bin_ztcp(char *nam, char **args, Options ops, UNUSED(int func))
|
||||||
}
|
}
|
||||||
|
|
||||||
if (targetfd) {
|
if (targetfd) {
|
||||||
if (redup(sess->fd,targetfd) == -1)
|
sess->fd = redup(sess->fd, targetfd);
|
||||||
sess->fd = -1;
|
|
||||||
else
|
|
||||||
sess->fd = targetfd;
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
/* move the fd since no one will want to read from it */
|
/* move the fd since no one will want to read from it */
|
||||||
|
|
@ -547,8 +544,11 @@ bin_ztcp(char *nam, char **args, Options ops, UNUSED(int func))
|
||||||
}
|
}
|
||||||
|
|
||||||
if (targetfd) {
|
if (targetfd) {
|
||||||
redup(rfd, targetfd);
|
sess->fd = redup(rfd, targetfd);
|
||||||
sess->fd = targetfd;
|
if (sess->fd < 0) {
|
||||||
|
zerrnam(nam, "could not duplicate socket fd to %d: %e", targetfd, errno);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
sess->fd = rfd;
|
sess->fd = rfd;
|
||||||
|
|
@ -662,8 +662,11 @@ bin_ztcp(char *nam, char **args, Options ops, UNUSED(int func))
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (targetfd) {
|
if (targetfd) {
|
||||||
redup(sess->fd, targetfd);
|
sess->fd = redup(sess->fd, targetfd);
|
||||||
sess->fd = targetfd;
|
if (sess->fd < 0) {
|
||||||
|
zerrnam(nam, "could not duplicate socket fd to %d: %e", targetfd, errno);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
setiparam("REPLY", sess->fd);
|
setiparam("REPLY", sess->fd);
|
||||||
|
|
|
||||||
|
|
@ -1654,14 +1654,14 @@ movefd(int fd)
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Move fd x to y. If x == -1, fd y is closed.
|
* Move fd x to y. If x == -1, fd y is closed.
|
||||||
* Return 0 for success, -1 for failure.
|
* Returns y for success, -1 for failure.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**/
|
/**/
|
||||||
mod_export int
|
mod_export int
|
||||||
redup(int x, int y)
|
redup(int x, int y)
|
||||||
{
|
{
|
||||||
int ret = 0;
|
int ret = y;
|
||||||
|
|
||||||
if(x < 0)
|
if(x < 0)
|
||||||
zclose(y);
|
zclose(y);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue