mirror of
https://github.com/neovim/neovim.git
synced 2024-12-31 17:13:26 -07:00
job control: implement jobpid() to get PID of job
This commit is contained in:
parent
49f0417988
commit
f338ea7835
@ -1894,6 +1894,7 @@ isdirectory( {directory}) Number TRUE if {directory} is a directory
|
|||||||
islocked( {expr}) Number TRUE if {expr} is locked
|
islocked( {expr}) Number TRUE if {expr} is locked
|
||||||
items( {dict}) List key-value pairs in {dict}
|
items( {dict}) List key-value pairs in {dict}
|
||||||
jobclose({job}[, {stream}]) Number Closes a job stream(s)
|
jobclose({job}[, {stream}]) Number Closes a job stream(s)
|
||||||
|
jobpid({job}) Number Returns pid of a job.
|
||||||
jobresize({job}, {width}, {height})
|
jobresize({job}, {width}, {height})
|
||||||
Number Resize {job}'s pseudo terminal window
|
Number Resize {job}'s pseudo terminal window
|
||||||
jobsend({job}, {data}) Number Writes {data} to {job}'s stdin
|
jobsend({job}, {data}) Number Writes {data} to {job}'s stdin
|
||||||
@ -4157,6 +4158,9 @@ jobclose({job}[, {stream}]) {Nvim} *jobclose()*
|
|||||||
Close {job}'s {stream}, which can be one "stdin", "stdout" or
|
Close {job}'s {stream}, which can be one "stdin", "stdout" or
|
||||||
"stderr". If {stream} is omitted, all streams are closed.
|
"stderr". If {stream} is omitted, all streams are closed.
|
||||||
|
|
||||||
|
jobpid({job}) {Nvim} *jobpid()*
|
||||||
|
Return the pid (process id) of {job}.
|
||||||
|
|
||||||
jobresize({job}, {width}, {height}) {Nvim} *jobresize()*
|
jobresize({job}, {width}, {height}) {Nvim} *jobresize()*
|
||||||
Resize {job}'s pseudo terminal window to {width} and {height}.
|
Resize {job}'s pseudo terminal window to {width} and {height}.
|
||||||
This function will fail if used on jobs started without the
|
This function will fail if used on jobs started without the
|
||||||
|
@ -7236,6 +7236,7 @@ static struct fst {
|
|||||||
{ "islocked", 1, 1, f_islocked },
|
{ "islocked", 1, 1, f_islocked },
|
||||||
{ "items", 1, 1, f_items },
|
{ "items", 1, 1, f_items },
|
||||||
{ "jobclose", 1, 2, f_jobclose },
|
{ "jobclose", 1, 2, f_jobclose },
|
||||||
|
{ "jobpid", 1, 1, f_jobpid },
|
||||||
{ "jobresize", 3, 3, f_jobresize },
|
{ "jobresize", 3, 3, f_jobresize },
|
||||||
{ "jobsend", 2, 2, f_jobsend },
|
{ "jobsend", 2, 2, f_jobsend },
|
||||||
{ "jobstart", 1, 2, f_jobstart },
|
{ "jobstart", 1, 2, f_jobstart },
|
||||||
@ -11611,6 +11612,31 @@ static void f_jobclose(typval_T *argvars, typval_T *rettv)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// "jobpid(id)" function
|
||||||
|
static void f_jobpid(typval_T *argvars, typval_T *rettv)
|
||||||
|
{
|
||||||
|
rettv->v_type = VAR_NUMBER;
|
||||||
|
rettv->vval.v_number = 0;
|
||||||
|
|
||||||
|
if (check_restricted() || check_secure()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (argvars[0].v_type != VAR_NUMBER) {
|
||||||
|
EMSG(_(e_invarg));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
TerminalJobData *data = find_job(argvars[0].vval.v_number);
|
||||||
|
if (!data) {
|
||||||
|
EMSG(_(e_invjob));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Process *proc = (Process *)&data->proc;
|
||||||
|
rettv->vval.v_number = proc->pid;
|
||||||
|
}
|
||||||
|
|
||||||
// "jobsend()" function
|
// "jobsend()" function
|
||||||
static void f_jobsend(typval_T *argvars, typval_T *rettv)
|
static void f_jobsend(typval_T *argvars, typval_T *rettv)
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user