Skip to content

Tunnel Wrapper and Getting PID? #2

@wrathematics

Description

@wrathematics

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions