mirror of
https://github.com/fish-shell/fish-shell
synced 2024-12-27 05:13:10 +00:00
Minor code edit - move a bit of code into its own function
darcs-hash:20061120131224-ac50b-974496cc800377e4e06475491f89998b9640fbba.gz
This commit is contained in:
parent
7b5649097f
commit
bc1efb1556
3 changed files with 40 additions and 19 deletions
34
proc.c
34
proc.c
|
@ -301,6 +301,40 @@ int job_get_flag( job_t *j, int flag )
|
||||||
return j->flags&flag?1:0;
|
return j->flags&flag?1:0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int job_signal( job_t *j, int signal )
|
||||||
|
{
|
||||||
|
pid_t my_pid = getpid();
|
||||||
|
int res = 0;
|
||||||
|
|
||||||
|
if( j->pgid != my_pid )
|
||||||
|
{
|
||||||
|
res = killpg( j->pgid, SIGHUP );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
process_t *p;
|
||||||
|
|
||||||
|
for( p = j->first_process; p; p=p->next )
|
||||||
|
{
|
||||||
|
if( ! p->completed )
|
||||||
|
{
|
||||||
|
if( p->pid )
|
||||||
|
{
|
||||||
|
if( kill( p->pid, SIGHUP ) )
|
||||||
|
{
|
||||||
|
res = -1;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
return res;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Store the status of the process pid that was returned by waitpid.
|
Store the status of the process pid that was returned by waitpid.
|
||||||
|
|
5
proc.h
5
proc.h
|
@ -366,6 +366,11 @@ int job_reap( int interactive );
|
||||||
*/
|
*/
|
||||||
void job_handle_signal( int signal, siginfo_t *info, void *con );
|
void job_handle_signal( int signal, siginfo_t *info, void *con );
|
||||||
|
|
||||||
|
/**
|
||||||
|
Send the specified signal to all processes in the specified job.
|
||||||
|
*/
|
||||||
|
int job_signal( job_t *j, int signal );
|
||||||
|
|
||||||
#ifdef HAVE__PROC_SELF_STAT
|
#ifdef HAVE__PROC_SELF_STAT
|
||||||
/**
|
/**
|
||||||
Use the procfs filesystem to look up how many jiffies of cpu time
|
Use the procfs filesystem to look up how many jiffies of cpu time
|
||||||
|
|
20
reader.c
20
reader.c
|
@ -1918,29 +1918,11 @@ static int read_i()
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
pid_t my_pid = getpid();
|
|
||||||
for( j = first_job; j; j=j->next )
|
for( j = first_job; j; j=j->next )
|
||||||
{
|
{
|
||||||
if( ! job_is_completed( j ) )
|
if( ! job_is_completed( j ) )
|
||||||
{
|
{
|
||||||
if( j->pgid != my_pid )
|
job_signal( j, SIGHUP );
|
||||||
{
|
|
||||||
killpg( j->pgid, SIGHUP );
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
process_t *p;
|
|
||||||
for( p = j->first_process; p; p=p->next )
|
|
||||||
{
|
|
||||||
if( ! p->completed )
|
|
||||||
{
|
|
||||||
if( p->pid )
|
|
||||||
{
|
|
||||||
kill( p->pid, SIGHUP );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue