-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[enhancement] make process exit status available to user #1
Comments
I've added Result to Expect which is filled in asynchronously with the Wait() result after the command exits For an example of its use see the func showWaitResult() in expect_test.go |
Thank you. With apologies, I think what I wrote above was misleading. Initially I thought all that is needed is to somehow capture the result, but did not realize my suggestion had these drawbacks:
I am facing this use case:
Would you be open to a solution that exposes This would make it much simpler. I am not a fan of forking things just because 1 feature is missing, this is something I need to make work in the application. |
I have added a proof-of-concept in my current branch, could you please have a look? I was thinking you did not like to expose internals, so I have made it a separate There were a few other changes: I made the package context.Context aware, since this is now officially supported in Go >= 1.7, i.e. the os/exec package will terminate the process via I hope we can collaborate on this, if necessary I can open a separate issue. |
Hi I'd just pushed my own changes before seeing this. I've added NewExpectProc that returns the Cmd to allow the caller to take control of it. I'm looking at your version now but I'm not that familiar with Contexts so it may take a while for me to understand it |
I will have a more detailed look after work. Likely we can put this on hold until these things have been sorted out, at which time I can send more clearly separated patches. At the moment I am working on integrating the expect package into the use case I am facing (interfacing with python/ansible scripts). I have found context very useful, in particular when using many concurrent goroutines. It is essentially just a wrapper around a When properly integrated, it allows to cancel all (nested) goroutines on program or call termination, from a single point. One area I have found this very useful in is to set up a signal handler for a program, which handles a signal by canceling the context. |
I had a look at 39b84f8, liked the progress. The recent 2 changes are somewhat complementary,
I found that there is a happy combination of both approaches - by simply using Perhaps we can return to this later, I am facing another problem, will document that separately. |
@leemcloughlin - over a year has passed since this issue was opened. When I just reconsolidated my fork at https://github.com/grrtrr/expect/commits/master, I saw that there are a few commits that to me seem very useful. The most important one of them is to add a cancellation context, which the above referred to. Without the ability to Since I needed those features, I have put them into my forked master branch. Would they make sense for you -- I would be happy to work on a new PR? |
Hi Gerrit
Sorry I've been so late on investigating your commits - just been so
swamped since I changed jobs.
It wont be till the end of the month before I can properly reply.
I know that contexts are now required and expect needs them, and thanks for
your work on adding them, but I really dont like contexts. They sort of
infect func's and spread... sigh
Best regards
Lee McLoughlin CTO LMMR Technologies
<http://uk.linkedin.com/pub/lee-mcloughlin/1/973/481>
…On 6 November 2017 at 21:40, Gerrit Renker ***@***.***> wrote:
@leemcloughlin <https://github.com/leemcloughlin> - over a year has
passed since this issue was opened.
When I just reconsolidated my fork at https://github.com/grrtrr/
expect/commits/master, I saw that there are a few commits that to me seem
very useful.
The most important one of them is to add a cancellation context
<https://blog.golang.org/context>, which the above referred to.
Since I needed those features, I have put them into my forked master
branch. Would they make sense for you -- I would be happy to work on a new
PR?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#1 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AKxT74_4d5QK0_QlH1ok0AaUoV0-bVVyks5sz3zcgaJpZM4KkRBN>
.
|
Lee, please do take your time - a few weeks more or less will not matter. When it comes to People have abused the untyped key/value interface of the context package to pass values around, and The problem that Once an autonomous goroutine is started, the only way to stop it is to pass a "channel" in that tells it when to stop. Doing this ad-hoc, in hundreds of functions and goroutines, leads to clutter. With the Several low-level packages ( For concurrent batch-processing, I have found |
Thank you for this useful package, I have been looking for something like this for a long time;
having used tcl/expect in the past, the other go-based packages were not what I expected (pun
not intended).
Problem
The
expect
package provides aKill
function, which can be used to stop a process after interacting with it through thepty
.For the use case of a normally terminating process (e.g. running an ssh process with password prompt, which then executes a single remote command), there is no way of querying the exit status.
This information can be very useful to evaluate, in addition to the command-stdout/stderr buffer.
Requested enhancement
Expose, in some form, the return value (
*os.ProcessState, error
) ofcmd.Process.Wait
.The text was updated successfully, but these errors were encountered: