Skip to content

Commit

Permalink
Fix locking error in spawn implementation
Browse files Browse the repository at this point in the history
This applies a patch from OpenSUSE. Source:
https://build.opensuse.org/package/view_file/shells/ksh/ksh93-spawnlock.dif

| Wed Oct 12 13:23:14 CEST 2016 - mls@suse.de
|
| - fix locking error in spawn implementation [bnc#988213]
|   new patch: ksh93-spawnlock.dif

Unfortunately the bug report is not currently public:
https://bugzilla.opensuse.org/show_bug.cgi?id=988213
but this one seems sensible enough and is in production use,
so I'll take it on faith.
  • Loading branch information
McDutchie committed Jan 27, 2021
1 parent a5c53a5 commit 6d13526
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
4 changes: 4 additions & 0 deletions src/cmd/ksh93/sh/jobs.c
Original file line number Diff line number Diff line change
Expand Up @@ -1947,6 +1947,10 @@ void job_fork(pid_t parent)
job_lock();
jobfork++;
break;
case -2:
jobfork--;
job_unlock();
break;
case 0:
jobfork=0;
job_unlock();
Expand Down
4 changes: 3 additions & 1 deletion src/cmd/ksh93/sh/xec.c
Original file line number Diff line number Diff line change
Expand Up @@ -3631,6 +3631,7 @@ static pid_t sh_ntfork(Shell_t *shp,const Shnode_t *t,char *argv[],int *jobid,in
# endif /* !_lib_fork */
sh_pushcontext(shp,buffp,SH_JMPCMD);
errorpush(&buffp->err,ERROR_SILENT);
job_lock(); /* errormsg will unlock */
jmpval = sigsetjmp(buffp->buff,0);
if(jmpval == 0)
{
Expand Down Expand Up @@ -3732,14 +3733,15 @@ static pid_t sh_ntfork(Shell_t *shp,const Shnode_t *t,char *argv[],int *jobid,in
}
fail:
if(jobfork && spawnpid<0)
job_fork(0);
job_fork(-2);
if(spawnpid < 0) switch(errno=shp->path_err)
{
case ENOENT:
errormsg(SH_DICT,ERROR_system(ERROR_NOENT),e_found+4);
default:
errormsg(SH_DICT,ERROR_system(ERROR_NOEXEC),e_exec+4);
}
job_unlock();
}
else
exitset();
Expand Down

0 comments on commit 6d13526

Please sign in to comment.