This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
8238f7f2f195e2032ad180ec7b387ebcf45a39c4
[metaconfig.git] / U / modified / d_setpgrp.U
1 ?RCS: $Id: d_setpgrp.U,v 3.0.1.3 1997/02/28 15:44:16 ram Exp $
2 ?RCS:
3 ?RCS: Copyright (c) 1991-1993, Raphael Manfredi
4 ?RCS:
5 ?RCS: You may redistribute only under the terms of the Artistic License,
6 ?RCS: as specified in the README file that comes with the distribution.
7 ?RCS: You may reuse parts of this distribution only within the terms of
8 ?RCS: that same Artistic License; a copy of which may be found at the root
9 ?RCS: of the source tree for dist 3.0.
10 ?RCS:
11 ?RCS: $Log: d_setpgrp.U,v $
12 ?RCS: Revision 3.0.1.3  1997/02/28  15:44:16  ram
13 ?RCS: patch61: obsoleted USE_BSDGRP in favor of USE_BSD_SETPGRP
14 ?RCS: patch61: another unit now also defines a USE_BSD_GETPGRP
15 ?RCS: patch61: fallback for test program failure improved
16 ?RCS:
17 ?RCS: Revision 3.0.1.2  1995/07/25  13:59:30  ram
18 ?RCS: patch56: re-arranged compile line to include ldflags before objects
19 ?RCS:
20 ?RCS: Revision 3.0.1.1  1994/10/29  16:15:37  ram
21 ?RCS: patch36: added 'ldflags' to the test compile line (ADO)
22 ?RCS: patch36: call ./usg explicitly instead of relying on PATH
23 ?RCS:
24 ?RCS: Revision 3.0  1993/08/18  12:07:09  ram
25 ?RCS: Baseline for dist 3.0 netwide release.
26 ?RCS:
27 ?MAKE:d_setpgrp d_bsdsetpgrp: cat rm_try +cc +libs +ccflags \
28         +ldflags Inlibc Guess Setvar i_unistd i_stdlib run
29 ?MAKE:  -pick add $@ %<
30 ?S:d_setpgrp:
31 ?S:     This variable conditionally defines HAS_SETPGRP if setpgrp() is
32 ?S:     available to set the current process group.
33 ?S:.
34 ?S:d_bsdsetpgrp (d_bsdpgrp):
35 ?S:     This variable conditionally defines USE_BSD_SETPGRP if
36 ?S:     setpgrp needs two arguments whereas USG one needs none.
37 ?S:     See also d_setpgid for a POSIX interface.
38 ?S:.
39 ?C:HAS_SETPGRP (SETPGRP):
40 ?C:     This symbol, if defined, indicates that the setpgrp routine is
41 ?C:     available to set the current process group.
42 ?C:.
43 ?C:USE_BSD_SETPGRP (USE_BSDPGRP BSDPGRP):
44 ?C:     This symbol, if defined, indicates that setpgrp needs two
45 ?C:     arguments whereas USG one needs none.  See also HAS_SETPGID
46 ?C:     for a POSIX interface.
47 ?C:.
48 ?H:#$d_setpgrp HAS_SETPGRP              /**/
49 ?H:#$d_bsdsetpgrp USE_BSD_SETPGRP       /**/
50 ?H:.
51 ?T:xxx
52 ?F:!try
53 ?LINT:set d_setpgrp d_bsdsetpgrp
54 : see if setpgrp exists
55 set setpgrp d_setpgrp
56 eval $inlibc
57
58 @if USE_BSD_SETPGRP || d_bsdsetpgrp
59 case "$d_setpgrp" in
60 "$define")
61         echo " "
62         echo "Checking to see which flavor of setpgrp is in use..."
63         $cat >try.c <<EOP
64 #$i_unistd I_UNISTD
65 #include <sys/types.h>
66 #ifdef I_UNISTD
67 #  include <unistd.h>
68 #endif
69 #$i_stdlib I_STDLIB
70 #ifdef I_STDLIB
71 #include <stdlib.h>
72 #endif
73 int main()
74 {
75         if (getuid() == 0) {
76                 printf("(I see you are running Configure as super-user...)\n");
77                 setuid(1);
78         }
79 #ifdef TRY_BSD_PGRP
80         if (-1 == setpgrp(1, 1))
81                 exit(0);
82 #else
83         if (setpgrp() != -1)
84                 exit(0);
85 #endif
86         exit(1);
87 }
88 EOP
89         if $cc -o try -DTRY_BSD_PGRP $ccflags $ldflags try.c $libs >/dev/null 2>&1 && $run ./try; then
90                 echo 'You have to use setpgrp(pid,pgrp) instead of setpgrp().' >&4
91                 val="$define"
92         elif $cc -o try $ccflags $ldflags try.c $libs >/dev/null 2>&1 && $run ./try; then
93                 echo 'You have to use setpgrp() instead of setpgrp(pid,pgrp).' >&4
94                 val="$undef"
95         else
96                 echo "(I can't seem to compile and run the test program.)"
97                 if ./usg; then
98                         xxx="a USG one, i.e. you use setpgrp()."
99                 else
100                         # SVR4 systems can appear rather BSD-ish.
101                         case "$i_unistd" in
102                         $undef)
103                                 xxx="a BSD one, i.e. you use setpgrp(pid,pgrp)."
104                                 val="$define"
105                                 ;;
106                         $define)
107                                 xxx="probably a USG one, i.e. you use setpgrp()."
108                                 val="$undef"
109                                 ;;
110                         esac
111                 fi
112                 echo "Assuming your setpgrp is $xxx" >&4
113         fi
114         ;;
115 *) val="$undef";;
116 esac
117 set d_bsdsetpgrp
118 eval $setvar
119 $rm_try
120 @end
121