mirror of
https://github.com/fish-shell/fish-shell.git
synced 2024-11-23 14:40:37 +08:00
Make the bg builtin check that all specified jobs exist before sending any of them to background. Also make sure that the string to pid conversion didn't throw errors.
darcs-hash:20070109002144-ac50b-c3954d98bab5cd95699966b2d1f2480797a9094d.gz
This commit is contained in:
parent
bc2c37c739
commit
41206e70b4
30
builtin.c
30
builtin.c
|
@ -2478,12 +2478,36 @@ static int builtin_bg( wchar_t **argv )
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
for( argv++; !res && *argv != 0; argv++ )
|
wchar_t *end;
|
||||||
|
int i;
|
||||||
|
int pid;
|
||||||
|
int err = 0;
|
||||||
|
|
||||||
|
for( i=1; argv[i]; i++ )
|
||||||
{
|
{
|
||||||
int pid = wcstol( *argv, 0, 10 );
|
errno=0;
|
||||||
res |= send_to_bg( job_get_from_pid( pid ), *argv);
|
pid = (int)wcstol( argv[i], &end, 10 );
|
||||||
|
if( errno || pid < 0 || *end || !job_get_from_pid( pid ) )
|
||||||
|
{
|
||||||
|
sb_printf( sb_err,
|
||||||
|
_( L"%ls: '%ls' is not a job\n" ),
|
||||||
|
argv[0],
|
||||||
|
argv[i] );
|
||||||
|
err = 1;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if( !err )
|
||||||
|
{
|
||||||
|
for( i=1; !res && argv[i]; i++ )
|
||||||
|
{
|
||||||
|
pid = (int)wcstol( argv[i], 0, 10 );
|
||||||
|
res |= send_to_bg( job_get_from_pid( pid ), *argv);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user