How to run a process in the background inside Gvim?

Go To StackoverFlow.com

3

Well, what I need to do actually is CTRL-Z out of a process that got started from insert mode in GVim.

My command :Cdprun executes cdprun.sh which runs a sudo-ed daemon. I can add & at the end of the sudo-ed daemon call to run in the background and that works but the user doesn't get prompted for a password. Instead I want to just CTRL-Z out of it but the keyboard interrupt doesn't work. Any ideas? Thx.

2012-04-05 18:25
by Mario Aguilera
Why do you need a keyboard interrupt? To abort the daemon or come back Gvim while the daemon is running - romainl 2012-04-05 19:20


2

You generally have two options in this case: generic is using something like vim-addon-async mentioned by @Nicalas Martin or vim with built-in interpreters support: tcl with expect module, python with pyexpect, perl with Expect, maybe something else (note: all of the mentioned packages are not shipped with tcl/python/perl). Second is specific to current situation: it is backgrounding in the other place. From your explanation I guessed that you have a script looking like

#!/bin/sh
<...>
sudo run-daemon --daemon-args # Last executed line

, am I right? Than you can just put backgrounding in another place: not

sudo run-daemon --daemon-args &

, but

sudo sh -c "nohup run-daemon --daemon-args &"
2012-04-07 16:50
by ZyX


0

Here is a script to deal with asynchronous command in vim. Not a perfect solution but could be a good temporary solution. http://www.vim.org/scripts/script.php?script_id=3307

2012-04-05 19:23
by Nicolas Martin
Ads