Skip to content

Commit

Permalink
Fix two bugs in the jobs builtin, causing freezes and other incorrect…
Browse files Browse the repository at this point in the history
… behaviours

darcs-hash:20060424153434-ac50b-2434329395cbd4a258d6fb9f15e166065b2eb164.gz
  • Loading branch information
liljencrantz committed Apr 24, 2006
1 parent 13a7269 commit 445f653
Showing 1 changed file with 31 additions and 18 deletions.
49 changes: 31 additions & 18 deletions builtin.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 )
{
Expand Down Expand Up @@ -2127,27 +2127,40 @@ static int builtin_fg( wchar_t **argv )
}
else
{
int pid = abs(wcstol( argv[1], 0, 10 ));
j = job_get_from_pid( pid );
if( !j )
wchar_t *end;
int pid = abs(wcstol( argv[1], &end, 10 ));

if( *end )
{
sb_printf( sb_err,
_( L"%ls: No suitable job: %d\n" ),
argv[0],
pid );
builtin_print_help( argv[0], sb_err );
sb_printf( sb_err,
_( L"%ls: Argument must be a number: %ls\n" ),
argv[0],
argv[1] );
builtin_print_help( argv[0], sb_err );
}
if( !j->job_control )
else
{
sb_printf( sb_err,
_( L"%ls: Can't put job %d, '%ls' to foreground because it is not under job control\n" ),
argv[0],
pid,
j->command );
builtin_print_help( argv[0], sb_err );
j=0;
j = job_get_from_pid( pid );
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;
}
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" ),
argv[0],
pid,
j->command );
builtin_print_help( argv[0], sb_err );
j=0;
}
}

}

if( j )
Expand Down

0 comments on commit 445f653

Please sign in to comment.