M port/portdat.h => port/portdat.h +2 -1
@@ 315,7 315,8 @@ enum
SG_PHYSICAL = 05,
SG_SHDATA = 06,
- SG_RONLY = 040, /* Segment is read only */
+ SG_RONLY = 0040, /* Segment is read only */
+ SG_CEXEC = 0100, /* Detach at exec */
};
#define PG_ONSWAP 1
M port/sysproc.c => port/sysproc.c +9 -1
@@ 330,7 330,15 @@ sysexec(ulong *arg)
*/
for(i = SSEG; i <= BSEG; i++) {
putseg(up->seg[i]);
- up->seg[i] = 0; /* prevent a second free if we have an error */
+ /* prevent a second free if we have an error */
+ up->seg[i] = 0;
+ }
+ for(i = BSEG+1; i < NSEG; i++) {
+ s = up->seg[i];
+ if(s != 0 && (s->type&SG_CEXEC)) {
+ putseg(s);
+ up->seg[i] = 0;
+ }
}
/*