Bugzilla – Attachment 144 Details for
Bug 369
Inconsistant exit status from scp
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Check ssh's exit status in scp
scp-check-ssh-exit-status.patch (text/plain), 2.06 KB, created by
Thomas Binder
on 2002-09-12 00:43:21 AEST
(
hide
)
Description:
Check ssh's exit status in scp
Filename:
MIME Type:
Creator:
Thomas Binder
Created:
2002-09-12 00:43:21 AEST
Size:
2.06 KB
patch
obsolete
>? confdefs.h >Index: scp.c >=================================================================== >RCS file: /cvs/openssh/scp.c,v >retrieving revision 1.97 >diff -u -r1.97 scp.c >--- scp.c 21 Jun 2002 00:41:52 -0000 1.97 >+++ scp.c 10 Sep 2002 17:16:29 -0000 >@@ -125,6 +125,9 @@ > /* This is the program to execute for the secured connection. ("ssh" or -S) */ > char *ssh_program = _PATH_SSH_PROGRAM; > >+/* This is used to store the pid of ssh_program */ >+pid_t do_cmd_pid; >+ > /* > * This function executes the given command as the specified user on the > * given host. This returns < 0 if execution fails, and >= 0 otherwise. This >@@ -159,7 +162,8 @@ > close(reserved[1]); > > /* For a child to execute the command on the remote host using ssh. */ >- if (fork() == 0) { >+ do_cmd_pid = fork(); >+ if (do_cmd_pid == 0) { > /* Child. */ > close(pin[1]); > close(pout[0]); >@@ -178,6 +182,10 @@ > perror(ssh_program); > exit(1); > } >+ else if (do_cmd_pid == (pid_t)-1) { >+ /* fork() failed */ >+ fatal("fork: %s", strerror(errno)); >+ } > /* Parent. Close the other side, and return the local side. */ > close(pin[0]); > *fdout = pin[1]; >@@ -219,7 +227,7 @@ > int argc; > char *argv[]; > { >- int ch, fflag, tflag; >+ int ch, fflag, tflag, status; > char *targ; > extern char *optarg; > extern int optind; >@@ -317,6 +325,7 @@ > targetshouldbedirectory = 1; > > remin = remout = -1; >+ do_cmd_pid = (pid_t)-1; > /* Command to be executed on remote system using "ssh". */ > (void) snprintf(cmd, sizeof cmd, "scp%s%s%s%s", > verbose_mode ? " -v" : "", >@@ -331,6 +340,22 @@ > tolocal(argc, argv); /* Dest is local host. */ > if (targetshouldbedirectory) > verifydir(argv[argc - 1]); >+ } >+ /* >+ * Finally check the exit status of the ssh process, if one was forked >+ * and no error has occured yet >+ */ >+ if (do_cmd_pid != (pid_t)-1 && errs == 0) { >+ if (remin != -1) >+ (void) close(remin); >+ if (remout != -1) >+ (void) close(remout); >+ if (waitpid(do_cmd_pid, &status, 0) == -1) >+ errs = 1; >+ else { >+ if (!WIFEXITED(status) || WEXITSTATUS(status) != 0) >+ errs = 1; >+ } > } > exit(errs != 0); > }
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 369
: 144