Browse Source

Bugfix compilation too late pipes closing

Yann Weber 1 year ago
parent
commit
d8c833080f
1 changed files with 4 additions and 5 deletions
  1. 4
    5
      compile.c

+ 4
- 5
compile.c View File

@@ -226,12 +226,12 @@ int asmsh_asmc_compile_unsafe(asmsh_asmc_ctx_t *ctx, const char *_instr,
226 226
 	}
227 227
 	close(ctx->child.pipe_stdin);
228 228
 
229
-	FD_ZERO(&sigset);
230
-	FD_SET(sigfd, &sigset);
231 229
 
232 230
 	stimeout = ctx->ctimeout;
233 231
 	do
234 232
 	{
233
+		FD_ZERO(&sigset);
234
+		FD_SET(sigfd, &sigset);
235 235
 		if(select(sigfd+1, &sigset, NULL, NULL, &ctx->ctimeout) == 0)
236 236
 		{
237 237
 			//compilation timeout t_t
@@ -277,6 +277,8 @@ int asmsh_asmc_compile_unsafe(asmsh_asmc_ctx_t *ctx, const char *_instr,
277 277
 		goto err;
278 278
 	}
279 279
 
280
+	close(ctx->child.pipe_stdout[0]);
281
+	close(ctx->child.pipe_stdout[1]);
280 282
 	ctx->child.pid = 0;
281 283
 	if(ctx->pre_spawn && asmsh_asmc_spawn(ctx) == -1)
282 284
 	{
@@ -284,9 +286,6 @@ int asmsh_asmc_compile_unsafe(asmsh_asmc_ctx_t *ctx, const char *_instr,
284 286
 		perror("Unable to pre-spawn");
285 287
 		goto err;
286 288
 	}
287
-	
288
-	close(ctx->child.pipe_stdout[0]);
289
-	close(ctx->child.pipe_stdout[1]);
290 289
 
291 290
 	return asmh_asmc_bytecode_from_obj(ctx->respath, res);
292 291
 

Loading…
Cancel
Save