Skip to content
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

Tunnel Wrapper and Getting PID? #2

Open
wrathematics opened this issue Jan 10, 2017 · 2 comments
Open

Tunnel Wrapper and Getting PID? #2

wrathematics opened this issue Jan 10, 2017 · 2 comments

Comments

@wrathematics
Copy link
Contributor

wrathematics commented Jan 10, 2017

I think tunneling should get a wrapper. Something like:

#' tunnel
#' 
#' @param hostname
#' the server ip or host name.
#' @param lport,rport
#' local and remote ports.
#' @param pport,user,hostname,priv.key,priv.key.ppk,intern,wait
#' See \code{?pbdRPC::rpc}.
#' 
#' @export
tunnel <- function(pport = .pbd_env$RPC.LI$pport, user = .pbd_env$RPC.LI$user, 
    hostname = .pbd_env$RPC.LI$hostname, priv.key = .pbd_env$RPC.LI$priv.key, 
    priv.key.ppk = .pbd_env$RPC.LI$priv.key.ppk, intern = .pbd_env$RPC.CT$intern, 
    wait = .pbd_env$RPC.CT$wait, lport=55555, rport=55555)
{
  args <- paste0("-N -T -L ", lport, ":", "127.0.0.1", ":", rport)
  ret <- rpc(cmd="", args=args, pport=pport, user=user, hostname=hostname, priv.key=priv.key, priv.key.ppk=priv.key.ppk, intern=intern, wait=wait)
  invisible(ret)
}

The one problem with this, as you point out in the vignette, is the complication if wait=FALSE. Do you think it's possible to get the PID of the spawned process? I believe I know how to do this on *nix, but have no idea how you're spawning processes on windows. It would be nice if the function would either return the PID when wait=FALSE or even print it as a warning (reminding the user to kill it themselves).

What do you think?

@snoweye
Copy link
Owner

snoweye commented Jan 12, 2017

OK. Windows has a way to kill process by name not pid. I will do it when I have time.

@snoweye
Copy link
Owner

snoweye commented Jan 15, 2017

I tested it. They look good to me now. The example is in the vignettes.

snoweye added a commit that referenced this issue Aug 29, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants