Use a pty for prefixed output instead of pipes for stdout/stderr. This
is so that programs can get information about the controlling terminal.
This change was triggered by bug #188506 where it's possible that
stdin, stdout and stderr didn't point to a terminal but ended up on one
via our pipes. Using a pty means that stdout and stderr always point to
a terminal, but we lose the ability to tell them apart.
If there is not a pty available then we use un-prefixed output as normal.
This change has also introduced the need for a signal pipe so that
SIGCHLD can exit the loop cleanly.

1

/*

2

einfo.c

3

Gentoo informational functions

4

Copyright 2007 Gentoo Foundation

5

*/

6

7

#include<sys/types.h>

8

#include<sys/ioctl.h>

9

#include<sys/stat.h>

10

#include<errno.h>

11

#include<fcntl.h>

12

#include<limits.h>

13

#include<stdarg.h>

14

#include<stdbool.h>

15

#include<stdio.h>

16

#include<stdlib.h>

17

#include<string.h>

18

#include<syslog.h>

19

#include<unistd.h>

20

21

#include"einfo.h"

22

#include"rc.h"

23

#include"rc-misc.h"

24

25

#include"hidden-visibility.h"

26

hidden_proto(ecolor)

27

hidden_proto(ebegin)

28

hidden_proto(ebeginv)

29

hidden_proto(ebracket)

30

hidden_proto(eend)

31

hidden_proto(eendv)

32

hidden_proto(eerror)

33

hidden_proto(eerrorn)

34

hidden_proto(eerrorx)

35

hidden_proto(eindent)

36

hidden_proto(eindentv)

37

hidden_proto(einfo)

38

hidden_proto(einfon)

39

hidden_proto(einfov)

40

hidden_proto(einfovn)

41

hidden_proto(elog)

42

hidden_proto(eoutdent)

43

hidden_proto(eoutdentv)

44

hidden_proto(ewarn)

45

hidden_proto(ewarnn)

46

hidden_proto(ewarnv)

47

hidden_proto(ewarnvn)

48

hidden_proto(ewarnx)

49

hidden_proto(ewend)

50

hidden_proto(ewendv)

51

52

/* Incase we cannot work out how many columns from ioctl, supply a default */