mirror of
https://github.com/fish-shell/fish-shell.git
synced 2026-05-27 16:51:15 -03:00
More work towards improving relationship between multithreading and fork
This commit is contained in:
30
postfork.cpp
30
postfork.cpp
@@ -32,19 +32,6 @@
|
||||
#define FD_ERROR _( L"An error occurred while redirecting file descriptor %d" )
|
||||
|
||||
|
||||
/**
|
||||
This function should be called by both the parent process and the
|
||||
child right after fork() has been called. If job control is
|
||||
enabled, the child is put in the jobs group, and if the child is
|
||||
also in the foreground, it is also given control of the
|
||||
terminal. When called in the parent process, this function may
|
||||
fail, since the child might have already finished and called
|
||||
exit. The parent process may safely ignore the exit status of this
|
||||
call.
|
||||
|
||||
Returns 0 on sucess, -1 on failiure.
|
||||
*/
|
||||
|
||||
// PCA These calls to debug are rather sketchy because they may allocate memory. Fortunately they only occur if an error occurs.
|
||||
int set_child_group( job_t *j, process_t *p, int print_errors )
|
||||
{
|
||||
@@ -61,6 +48,7 @@ int set_child_group( job_t *j, process_t *p, int print_errors )
|
||||
{
|
||||
if( getpgid( p->pid) != j->pgid && print_errors )
|
||||
{
|
||||
// PCA FIXME This is sketchy to do in a forked child because it may allocate memory. This needs to call only safe functions.
|
||||
debug( 1,
|
||||
_( L"Could not send process %d, '%ls' in job %d, '%ls' from group %d to group %d" ),
|
||||
p->pid,
|
||||
@@ -284,22 +272,6 @@ static int handle_child_io( io_data_t *io )
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Initialize a new child process. This should be called right away
|
||||
after forking in the child process. If job control is enabled for
|
||||
this job, the process is put in the process group of the job, all
|
||||
signal handlers are reset, signals are unblocked (this function may
|
||||
only be called inside the exec function, which blocks all signals),
|
||||
and all IO redirections and other file descriptor actions are
|
||||
performed.
|
||||
|
||||
\param j the job to set up the IO for
|
||||
\param p the child process to set up
|
||||
|
||||
\return 0 on sucess, -1 on failiure. When this function returns,
|
||||
signals are always unblocked. On failiure, signal handlers, io
|
||||
redirections and process group of the process is undefined.
|
||||
*/
|
||||
int setup_child_process( job_t *j, process_t *p )
|
||||
{
|
||||
int res=0;
|
||||
|
||||
Reference in New Issue
Block a user