summaryrefslogtreecommitdiff
path: root/attach.c
diff options
context:
space:
mode:
Diffstat (limited to 'attach.c')
-rw-r--r--attach.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/attach.c b/attach.c
index 5fd301c..8ac3bf3 100644
--- a/attach.c
+++ b/attach.c
@@ -170,7 +170,11 @@ attach_main(int noerror)
if (chdir(sockname) >= 0)
{
s = connect_socket(slash + 1);
- fchdir(dirfd);
+ if (s >= 0 && fchdir(dirfd) < 0)
+ {
+ close(s);
+ s = -1;
+ }
}
*slash = '/';
close(dirfd);
@@ -315,7 +319,11 @@ push_main()
if (chdir(sockname) >= 0)
{
s = connect_socket(slash + 1);
- fchdir(dirfd);
+ if (s >= 0 && fchdir(dirfd) < 0)
+ {
+ close(s);
+ s = -1;
+ }
}
*slash = '/';
close(dirfd);