Tcl Source Code

Check-in [039305c274]
Login
EuroTcl/OpenACS 11 - 12 JULY 2024, VIENNA

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Christian's proposal for [407b70361c]: New test failures. Maybe unix pipe troubles? Not sure if this is really needed.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | bug-407b70361c
Files: files | file ages | folders
SHA3-256: 039305c27426e7ed3e83114f2060ba47550cbe998c4a2be18f300be29c1b985a
User & Date: jan.nijtmans 2024-05-22 11:29:26
References
2024-05-22
11:38 Ticket [407b70361c] New test failures. Maybe unix pipe troubles? status still Closed with 5 other changes artifact: af9e0ba784 user: jan.nijtmans
Context
2024-05-22
11:29
Christian's proposal for [407b70361c]: New test failures. Maybe unix pipe troubles? Not sure if this... Closed-Leaf check-in: 039305c274 user: jan.nijtmans tags: bug-407b70361c
10:22
cherry-pick [659ca0ae8da43a1e] for 8.6: don't need to invoke it in case if oPtr->selfCls is NULL check-in: 3ebb66feb1 user: sebres tags: core-8-6-branch
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to unix/tclUnixPipe.c.

496
497
498
499
500
501
502


503
504
505
506
507
508
509
510
511
512
513
514
515
516



517











518











519


520












521
522
523













524
525
526
527
528
529
530
    }
#endif
    status = -1;
    if (use_spawn) {
	posix_spawn_file_actions_t actions;
	posix_spawnattr_t attr;
	sigset_t sigs;



	posix_spawn_file_actions_init(&actions);
	posix_spawnattr_init(&attr);
	sigfillset(&sigs);
	sigdelset(&sigs, SIGKILL);
	sigdelset(&sigs, SIGSTOP);

	posix_spawnattr_setflags(&attr, POSIX_SPAWN_SETSIGDEF
#ifdef POSIX_SPAWN_USEVFORK
		| POSIX_SPAWN_USEVFORK
#endif
		);
	posix_spawnattr_setsigdefault(&attr, &sigs);




	posix_spawn_file_actions_adddup2(&actions, GetFd(inputFile), 0);











	posix_spawn_file_actions_adddup2(&actions, GetFd(outputFile), 1);











	posix_spawn_file_actions_adddup2(&actions, GetFd(errorFile), 2);















	status = posix_spawnp(&pid, newArgv[0], &actions, &attr,
		newArgv, environ);
	childErrno = errno;













	posix_spawn_file_actions_destroy(&actions);
	posix_spawnattr_destroy(&attr);

	/*
	 * Fork semantics:
	 *  - pid == 0: child process
	 *  - pid == -1: error







>
>














>
>
>
|
>
>
>
>
>
>
>
>
>
>
>
|
>
>
>
>
>
>
>
>
>
>
>
|
>
>
|
>
>
>
>
>
>
>
>
>
>
>
>



>
>
>
>
>
>
>
>
>
>
>
>
>







496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
    }
#endif
    status = -1;
    if (use_spawn) {
	posix_spawn_file_actions_t actions;
	posix_spawnattr_t attr;
	sigset_t sigs;
	long setfd[3];
	char restore[3] = { 0, 0, 0 };

	posix_spawn_file_actions_init(&actions);
	posix_spawnattr_init(&attr);
	sigfillset(&sigs);
	sigdelset(&sigs, SIGKILL);
	sigdelset(&sigs, SIGSTOP);

	posix_spawnattr_setflags(&attr, POSIX_SPAWN_SETSIGDEF
#ifdef POSIX_SPAWN_USEVFORK
		| POSIX_SPAWN_USEVFORK
#endif
		);
	posix_spawnattr_setsigdefault(&attr, &sigs);

	fd = GetFd(inputFile);
	setfd[0] = fcntl(fd, F_GETFD);
	if (fd != 0) {
	    posix_spawn_file_actions_adddup2(&actions, fd, 0);
	    if (setfd[0] & FD_CLOEXEC) {
		posix_spawn_file_actions_addclose(&actions, fd);
	    }
	} else if (setfd[0] & FD_CLOEXEC) {
	    fcntl(0, F_SETFD, setfd[0] & ~FD_CLOEXEC);
	    restore[0]++;
	}

	fd = GetFd(outputFile);
	setfd[1] = fcntl(fd, F_GETFD);
	if (fd != 1) {
	    posix_spawn_file_actions_adddup2(&actions, fd, 1);
	    if (setfd[1] & FD_CLOEXEC) {
		posix_spawn_file_actions_addclose(&actions, fd);
	    }
	} else if (setfd[1] & FD_CLOEXEC) {
	    fcntl(1, F_SETFD, setfd[1] & ~FD_CLOEXEC);
	    restore[1]++;
	}

	fd = GetFd(errorFile);
	setfd[2] = fcntl(fd, F_GETFD);
	if (fd != 2) {
	    posix_spawn_file_actions_adddup2(&actions, fd, 2);
	    if (setfd[2] & FD_CLOEXEC) {
		posix_spawn_file_actions_addclose(&actions, fd);
	    }
	} else if (setfd[2] & FD_CLOEXEC) {
	    fcntl(2, F_SETFD, setfd[2] & ~FD_CLOEXEC);
	    restore[2]++;
	}

	/*
	 * Potential timing problem: file descriptors 0/1/2
	 * can have their FD_CLOEXEC flags cleared for the
	 * duration of the posix_spawnp() invocation. This
	 * could be eliminated by serializing with a mutex.
	 */

	status = posix_spawnp(&pid, newArgv[0], &actions, &attr,
		newArgv, environ);
	childErrno = errno;

	if (restore[0]) {
	    fcntl(0, F_SETFD, setfd[0]);
	}

	if (restore[1]) {
	    fcntl(1, F_SETFD, setfd[1]);
	}

	if (restore[2]) {
	    fcntl(2, F_SETFD, setfd[2]);
	}

	posix_spawn_file_actions_destroy(&actions);
	posix_spawnattr_destroy(&attr);

	/*
	 * Fork semantics:
	 *  - pid == 0: child process
	 *  - pid == -1: error