mirror of
https://github.com/fish-shell/fish-shell.git
synced 2025-01-18 09:32:47 +08:00
Fix two bugs in the jobs builtin, causing freezes and other incorrect behaviours
darcs-hash:20060424153434-ac50b-2434329395cbd4a258d6fb9f15e166065b2eb164.gz
This commit is contained in:
parent
13a7269378
commit
445f6539cf
23
builtin.c
23
builtin.c
|
@ -2077,7 +2077,7 @@ static void make_first( job_t *j )
|
|||
*/
|
||||
static int builtin_fg( wchar_t **argv )
|
||||
{
|
||||
job_t *j;
|
||||
job_t *j=0;
|
||||
|
||||
if( argv[1] == 0 )
|
||||
{
|
||||
|
@ -2127,17 +2127,30 @@ static int builtin_fg( wchar_t **argv )
|
|||
}
|
||||
else
|
||||
{
|
||||
int pid = abs(wcstol( argv[1], 0, 10 ));
|
||||
wchar_t *end;
|
||||
int pid = abs(wcstol( argv[1], &end, 10 ));
|
||||
|
||||
if( *end )
|
||||
{
|
||||
sb_printf( sb_err,
|
||||
_( L"%ls: Argument must be a number: %ls\n" ),
|
||||
argv[0],
|
||||
argv[1] );
|
||||
builtin_print_help( argv[0], sb_err );
|
||||
}
|
||||
else
|
||||
{
|
||||
j = job_get_from_pid( pid );
|
||||
if( !j )
|
||||
if( !j || !j->constructed || job_is_completed( j ))
|
||||
{
|
||||
sb_printf( sb_err,
|
||||
_( L"%ls: No suitable job: %d\n" ),
|
||||
argv[0],
|
||||
pid );
|
||||
builtin_print_help( argv[0], sb_err );
|
||||
j=0;
|
||||
}
|
||||
if( !j->job_control )
|
||||
else if( !j->job_control )
|
||||
{
|
||||
sb_printf( sb_err,
|
||||
_( L"%ls: Can't put job %d, '%ls' to foreground because it is not under job control\n" ),
|
||||
|
@ -2147,7 +2160,7 @@ static int builtin_fg( wchar_t **argv )
|
|||
builtin_print_help( argv[0], sb_err );
|
||||
j=0;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
if( j )
|
||||
|
|
Loading…
Reference in New Issue
Block a user