1
0
mirror of https://git.FreeBSD.org/src.git synced 2024-12-16 10:20:30 +00:00

job make: if stdout is a tty create a pty when running a command.

This commit is contained in:
Max Khon 2011-12-15 03:13:23 +00:00
parent f8dee27442
commit 366cd46cbe
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=228521
2 changed files with 10 additions and 2 deletions

View File

@ -7,6 +7,8 @@ CFLAGS+=-I${.CURDIR}
SRCS= arch.c buf.c cond.c dir.c for.c hash.c hash_tables.c job.c \
lst.c main.c make.c parse.c proc.c shell.c str.c suff.c targ.c \
util.c var.c
DPADD= ${LIBUTIL}
LDADD= -lutil
NO_SHARED?= YES

View File

@ -115,6 +115,7 @@ __FBSDID("$FreeBSD$");
#include <fcntl.h>
#include <inttypes.h>
#include <limits.h>
#include <libutil.h>
#include <paths.h>
#include <string.h>
#include <signal.h>
@ -1798,8 +1799,13 @@ JobStart(GNode *gn, int flags, Job *previous)
if (usePipes) {
int fd[2];
if (pipe(fd) == -1)
Punt("Cannot create pipe: %s", strerror(errno));
if (isatty(1)) {
if (openpty(fd + 1, fd + 0, NULL, NULL, NULL) == -1)
Punt("Cannot open pty: %s", strerror(errno));
} else {
if (pipe(fd) == -1)
Punt("Cannot create pipe: %s", strerror(errno));
}
job->inPipe = fd[0];
job->outPipe = fd[1];
fcntl(job->inPipe, F_SETFD, 1);