summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArtyom V. Poptsov <poptsov.artyom@gmail.com>2015-02-08 20:38:05 +0300
committerArtyom V. Poptsov <poptsov.artyom@gmail.com>2015-02-08 20:38:05 +0300
commit2ee3781cbe53df68fa73aea6cfbedea587d654a4 (patch)
tree378bb5c46acb2ac9351f3495da7ad97dca3b2a4c
parentssh/version.c: Don't include `gcrypt.h' (diff)
downloadguile-ssh-2ee3781cbe53df68fa73aea6cfbedea587d654a4.tar.gz
ssh/channel.scm (channel-get-exit-status): New procedure
* ssh/channel-func.c (guile_ssh_channel_get_exit_status): New procedure. * ssh/channel-func.h: Update. * ssh/channel.scm (channel-get-exit-status): Export. * doc/api-channels.texi (Channels): Add description of `channel-get-exit-status'. * NEWS: Update.
-rw-r--r--ChangeLog10
-rw-r--r--NEWS3
-rw-r--r--doc/api-channels.texi7
-rw-r--r--ssh/channel-func.c22
-rw-r--r--ssh/channel-func.h4
-rw-r--r--ssh/channel.scm1
6 files changed, 45 insertions, 2 deletions
diff --git a/ChangeLog b/ChangeLog
index 6cd9b46..5ac4d6e 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2015-02-08 Artyom Poptsov <poptsov.artyom@gmail.com>
+
+ * ssh/channel-func.c (guile_ssh_channel_get_exit_status): New
+ procedure.
+ * ssh/channel-func.h: Update.
+ * ssh/channel.scm (channel-get-exit-status): Export.
+ * doc/api-channels.texi (Channels): Add description of
+ `channel-get-exit-status'.
+ * NEWS: Update.
+
2014-10-13 Artyom Poptsov <poptsov.artyom@gmail.com>
* ssh/version.c: Don't include `gcrypt.h'.
diff --git a/NEWS b/NEWS
index 21ccf7e..6fe352b 100644
--- a/NEWS
+++ b/NEWS
@@ -11,6 +11,9 @@ Copyright (C) Artyom V. Poptsov <poptsov.artyom@gmail.com>
** Remove dependency on libgcrypt added by a mistake
** New `server-get' procedure in (ssh server)
The procedure can be used to retrieve server options.
+** New `channel-get-exit-status' procedure in (ssh channel)
+ The procedure allows to get exit status of an executed command from a
+ channel.
** Improve printing of Guile-SSH server objects
** Update documentation
- Add description of the new procedures.
diff --git a/doc/api-channels.texi b/doc/api-channels.texi
index 1ac2082..2ed0d63 100644
--- a/doc/api-channels.texi
+++ b/doc/api-channels.texi
@@ -116,6 +116,13 @@ Return @code{#t} if remote has sent @acronym{EOF}, @code{#f} otherwise. Throw
@code{guile-ssh-error} if the channel has been closed and freed.
@end deffn
+@deffn {Scheme Procedure} channel-get-exit-status channel
+Get the exit status of the @var{channel} (error code from the executed
+instruction). The @var{channel} must be open. Return the exist status, or
+@code{#f} if no exit status has been returned (yet). Throw
+@code{guile-ssh-error} on error.
+@end deffn
+
@c Local Variables:
@c TeX-master: "guile-ssh.texi"
@c End:
diff --git a/ssh/channel-func.c b/ssh/channel-func.c
index 3907d9b..ebf6ad8 100644
--- a/ssh/channel-func.c
+++ b/ssh/channel-func.c
@@ -1,6 +1,6 @@
/* channel-func.c -- SSH channel manipulation functions.
*
- * Copyright (C) 2013, 2014 Artyom V. Poptsov <poptsov.artyom@gmail.com>
+ * Copyright (C) 2013, 2014, 2015 Artyom V. Poptsov <poptsov.artyom@gmail.com>
*
* This file is part of Guile-SSH.
*
@@ -79,6 +79,26 @@ Run a shell command CMD without an interactive shell.\
}
#undef FUNC_NAME
+SCM_DEFINE (guile_ssh_channel_get_exit_status,
+ "channel-get-exit-status", 1, 0, 0,
+ (SCM channel),
+ "\
+Get the exit status of the channel (error code from the executed \
+instruction). Return the exist status, or #f if no exit status has been \
+returned (yet). \
+")
+#define FUNC_NAME s_guile_ssh_channel_get_exit_status
+{
+ struct channel_data *cd = _scm_to_channel_data (channel);
+ int res;
+
+ GSSH_VALIDATE_OPEN_CHANNEL (channel, SCM_ARG1, FUNC_NAME);
+
+ res = ssh_channel_get_exit_status (cd->ssh_channel);
+ return (res == SSH_ERROR) ? SCM_BOOL_F : scm_from_int (res);
+}
+#undef FUNC_NAME
+
SCM_DEFINE (guile_ssh_channel_request_pty, "channel-request-pty", 1, 0, 0,
(SCM channel),
"\
diff --git a/ssh/channel-func.h b/ssh/channel-func.h
index 82afc23..dde74f9 100644
--- a/ssh/channel-func.h
+++ b/ssh/channel-func.h
@@ -1,4 +1,4 @@
-/* Copyright (C) 2013, 2014 Artyom V. Poptsov <poptsov.artyom@gmail.com>
+/* Copyright (C) 2013, 2014, 2015 Artyom V. Poptsov <poptsov.artyom@gmail.com>
*
* This file is part of Guile-SSH
*
@@ -27,6 +27,8 @@ extern SCM guile_ssh_channel_is_eof_p (SCM arg1);
extern SCM guile_ssh_channel_set_pty_size_x (SCM arg1, SCM arg2, SCM arg3);
+extern SCM guile_ssh_channel_get_exit_status (SCM arg1);
+
extern void init_channel_func (void);
#endif /* ifndef __CHANNEL_FUNC_H__ */
diff --git a/ssh/channel.scm b/ssh/channel.scm
index 821be7a..81500bc 100644
--- a/ssh/channel.scm
+++ b/ssh/channel.scm
@@ -57,6 +57,7 @@
channel-set-stream!
channel-get-stream
channel-get-session
+ channel-get-exit-status
channel-open?
channel-eof?))