1
0
mirror of https://git.FreeBSD.org/ports.git synced 2025-01-22 08:58:47 +00:00

Fix build on -current (cope with removal of union wait)

Submitted by:	mike
This commit is contained in:
Kris Kennaway 2002-10-26 01:16:02 +00:00
parent 9c233bec4b
commit 24a4637418
Notes: svn2git 2021-03-31 03:12:20 +00:00
svn path=/head/; revision=68842
9 changed files with 261 additions and 136 deletions

View File

@ -0,0 +1,12 @@
--- tclUnixPort.h.orig Fri Oct 25 10:45:48 2002
+++ tclUnixPort.h Fri Oct 25 10:45:15 2002
@@ -146,6 +146,9 @@
* The type of the status returned by wait varies from UNIX system
* to UNIX system. The macro below defines it:
*/
+#ifdef __FreeBSD__
+# define NO_UNION_WAIT
+#endif
#ifdef _AIX
# define WAIT_STATUS_TYPE pid_t

View File

@ -190,46 +190,6 @@ diff -c /var/tmp/sup/log.c sup/log.c
opened++;
}
diff -c /var/tmp/sup/run.c sup/run.c
*** run.c Fri Aug 20 17:46:33 1993
--- sup/run.c Thu Apr 6 13:32:15 1995
***************
*** 95,100 ****
--- 95,101 ----
#include <signal.h>
#include <sys/wait.h>
#include <varargs.h>
+ #define MAXARGS 100
static int dorun();
***************
*** 123,132 ****
{
int val;
va_list ap;
!
va_start(ap);
! val = runvp (name,ap);
va_end(ap);
return (val);
}
--- 124,137 ----
{
int val;
va_list ap;
! char *args[MAXARGS];
! int argno=0;
!
va_start(ap);
! while (argno < MAXARGS
! && (args[argno++] = va_arg(ap, char *)) != (char *)0);
va_end(ap);
+ val = runvp (name,args);
return (val);
}
diff -c /var/tmp/sup/scan.c sup/scan.c
*** scan.c Fri Aug 20 17:46:33 1993
--- sup/scan.c Sun Aug 13 18:44:51 1995

View File

@ -138,99 +138,3 @@ diff -u -r1.1.1.1 -r1.3
fprintf (noteF,"SUP Upgrade of %s at %s",
collrelname,ctime (&tloc));
(void) fflush (noteF);
Index: supfilesrv.c
===================================================================
RCS file: /home/ncvs/src/usr.sbin/sup/supfilesrv/supfilesrv.c,v
retrieving revision 1.4
retrieving revision 1.6
diff -u -r1.4 -r1.6
--- supfilesrv.c 1996/02/06 19:03:58 1.4
+++ supfilesrv.c 1996/09/24 08:43:04 1.6
@@ -254,7 +254,6 @@
#include <sys/wait.h>
#include <sys/stat.h>
#include <sys/file.h>
-#include <sys/dir.h>
#if MACH
#include <sys/ioctl.h>
#endif
@@ -277,7 +276,6 @@
#endif /* lint */
extern int errno;
-long time ();
uid_t getuid ();
int maxchildren;
@@ -1218,6 +1216,7 @@
register int fdtmp;
char sys_com[STRINGLENGTH], temp_file[STRINGLENGTH], rcs_file[STRINGLENGTH];
union wait status;
+ int wstat;
char *uconvert(),*gconvert();
int sendfile ();
@@ -1285,15 +1284,54 @@
#endif
if (fd == -1) {
if (docompress) {
- tmpnam(temp_file);
- sprintf(sys_com, "gzip -c < %s > %s\n", t->Tname, temp_file);
- if (system(sys_com) != 0) {
- /* Just in case */
- unlink(temp_file);
- goaway ("We died trying to \"%s\"", sys_com);
- t->Tmode = 0;
- }
- fd = open (temp_file,O_RDONLY,0);
+ FILE *tf;
+ int pid;
+ int i;
+
+ tf = tmpfile();
+ if (tf == NULL) {
+ goaway("no temp file");
+ t->Tmode = 0;
+ goto out;
+ }
+ pid = fork();
+ switch (pid) {
+ case -1: /* fail */
+ goaway("Could not fork");
+ t->Tmode = 0;
+ fclose(tf);
+ break;
+ case 0: /* child */
+ close(1);
+ dup(fileno(tf));/* write end */
+ for(i = 3; i < 64; i++)
+ close(i);
+ execl("/usr/bin/gzip", "sup-gzip", "-c", t->Tname, 0);
+ execl("/usr/local/bin/gzip", "sup-gzip", "-c", t->Tname, 0);
+ execlp("gzip", "sup-gzip", "-c", t->Tname, 0);
+ perror("gzip");
+ _exit(1); /* pipe breaks */
+ default: /* parent */
+ wait(&wstat);
+ if (WIFEXITED(wstat) &&
+ WEXITSTATUS(wstat) > 0) {
+ fclose(tf);
+ goaway("gzip failed!");
+ t->Tmode = 0;
+ goto out;
+ }
+ if (WIFSIGNALED(wstat)) {
+ fclose(tf);
+ goaway("gzip died!");
+ t->Tmode = 0;
+ goto out;
+ }
+ fd = dup(fileno(tf));
+ fclose(tf);
+ lseek(fd, 0, 0);
+ break;
+ }
+ out:
}
else
fd = open (t->Tname,O_RDONLY,0);

56
net/sup/files/patch-run.c Normal file
View File

@ -0,0 +1,56 @@
--- run.c.orig Fri Aug 20 20:46:33 1993
+++ run.c Fri Oct 25 10:23:26 2002
@@ -95,6 +95,7 @@
#include <signal.h>
#include <sys/wait.h>
#include <varargs.h>
+#define MAXARGS 100
static int dorun();
@@ -123,10 +124,14 @@
{
int val;
va_list ap;
-
+ char *args[MAXARGS];
+ int argno=0;
+
va_start(ap);
- val = runvp (name,ap);
+ while (argno < MAXARGS
+ && (args[argno++] = va_arg(ap, char *)) != (char *)0);
va_end(ap);
+ val = runvp (name,args);
return (val);
}
@@ -144,7 +149,7 @@
int wpid;
register int pid;
struct sigvec ignoresig,intsig,quitsig;
- union wait status;
+ int status;
int execvp(), execv();
int (*execrtn)() = usepath ? execvp : execv;
@@ -165,7 +170,7 @@
sigvec (SIGINT,&ignoresig,&intsig);
sigvec (SIGQUIT,&ignoresig,&quitsig);
do {
- wpid = wait3 (&status.w_status, WUNTRACED, 0);
+ wpid = wait3 (&status, WUNTRACED, 0);
if (WIFSTOPPED (status)) {
kill (0,SIGTSTP);
wpid = 0;
@@ -174,8 +179,8 @@
sigvec (SIGINT,&intsig,0); /* restore signals */
sigvec (SIGQUIT,&quitsig,0);
- if (WIFSIGNALED (status) || status.w_retcode == 0377)
+ if (WIFSIGNALED (status) || WEXITSTATUS(status) == 0377)
return (-1);
- return (status.w_retcode);
+ return (WEXITSTATUS(status));
}

View File

@ -0,0 +1,35 @@
--- supcmeat.c.orig Fri Oct 25 10:27:43 2002
+++ supcmeat.c Fri Oct 25 10:27:43 2002
@@ -1107,7 +1107,7 @@
{
struct stat sbuf;
struct timeval tbuf[2];
- union wait w;
+ int w;
if (thisC->Cflags&CFLIST) {
vnotify ("SUP Would execute %s\n",t->Tname);
@@ -1123,18 +1123,18 @@
notify ("SUP Unable to stat file %s\n", *name);
sbuf.st_ino = 0;
}
- w.w_status = system (t->Tname);
- if (WIFEXITED(w) && w.w_retcode != 0) {
+ w = system (t->Tname);
+ if (WIFEXITED(w) && WEXITSTATUS(w) != 0) {
notify ("SUP: Execute command returned failure status %#o\n",
- w.w_retcode);
+ WEXITSTATUS(w));
thisC->Cnogood = TRUE;
} else if (WIFSIGNALED(w)) {
notify ("SUP: Execute command killed by signal %d\n",
- w.w_termsig);
+ WTERMSIG(w));
thisC->Cnogood = TRUE;
} else if (WIFSTOPPED(w)) {
notify ("SUP: Execute command stopped by signal %d\n",
- w.w_stopsig);
+ WSTOPSIG(w));
thisC->Cnogood = TRUE;
}
if ((sbuf.st_ino != 0) && (sbuf.st_mode&S_IFMT) != S_IFLNK){

View File

@ -0,0 +1,107 @@
--- supfilesrv.c.orig Fri Oct 25 10:27:43 2002
+++ supfilesrv.c Fri Oct 25 10:30:55 2002
@@ -254,7 +254,6 @@
#include <sys/wait.h>
#include <sys/stat.h>
#include <sys/file.h>
-#include <sys/dir.h>
#if MACH
#include <sys/ioctl.h>
#endif
@@ -277,7 +276,6 @@
#endif /* lint */
extern int errno;
-long time ();
uid_t getuid ();
int maxchildren;
@@ -1217,7 +1215,8 @@
register int x,fd;
register int fdtmp;
char sys_com[STRINGLENGTH], temp_file[STRINGLENGTH], rcs_file[STRINGLENGTH];
- union wait status;
+ int status;
+ int wstat;
char *uconvert(),*gconvert();
int sendfile ();
@@ -1252,11 +1251,11 @@
sprintf(sys_com, "co -q -p %s %s > %s 2> /dev/null\n", rcs_release, t->Tname, rcs_file);
#endif
/*loginfo("using rcs mode \"%s\"\n", sys_com);*/
- status.w_status = system(sys_com);
- if (status.w_status < 0 || status.w_retcode) {
+ status = system(sys_com);
+ if (WTERMSIG(status) < 0 || WEXITSTATUS(status)) {
/* Just in case */
unlink(rcs_file);
- if (status.w_status < 0) {
+ if (WTERMSIG(status) < 0) {
goaway ("We died trying to \"%s\"", sys_com);
t->Tmode = 0;
}
@@ -1285,15 +1284,54 @@
#endif
if (fd == -1) {
if (docompress) {
- tmpnam(temp_file);
- sprintf(sys_com, "gzip -c < %s > %s\n", t->Tname, temp_file);
- if (system(sys_com) != 0) {
- /* Just in case */
- unlink(temp_file);
- goaway ("We died trying to \"%s\"", sys_com);
- t->Tmode = 0;
- }
- fd = open (temp_file,O_RDONLY,0);
+ FILE *tf;
+ int pid;
+ int i;
+
+ tf = tmpfile();
+ if (tf == NULL) {
+ goaway("no temp file");
+ t->Tmode = 0;
+ goto out;
+ }
+ pid = fork();
+ switch (pid) {
+ case -1: /* fail */
+ goaway("Could not fork");
+ t->Tmode = 0;
+ fclose(tf);
+ break;
+ case 0: /* child */
+ close(1);
+ dup(fileno(tf));/* write end */
+ for(i = 3; i < 64; i++)
+ close(i);
+ execl("/usr/bin/gzip", "sup-gzip", "-c", t->Tname, 0);
+ execl("/usr/local/bin/gzip", "sup-gzip", "-c", t->Tname, 0);
+ execlp("gzip", "sup-gzip", "-c", t->Tname, 0);
+ perror("gzip");
+ _exit(1); /* pipe breaks */
+ default: /* parent */
+ wait(&wstat);
+ if (WIFEXITED(wstat) &&
+ WEXITSTATUS(wstat) > 0) {
+ fclose(tf);
+ goaway("gzip failed!");
+ t->Tmode = 0;
+ goto out;
+ }
+ if (WIFSIGNALED(wstat)) {
+ fclose(tf);
+ goaway("gzip died!");
+ t->Tmode = 0;
+ goto out;
+ }
+ fd = dup(fileno(tf));
+ fclose(tf);
+ lseek(fd, 0, 0);
+ break;
+ }
+ out:
}
else
fd = open (t->Tname,O_RDONLY,0);

View File

@ -0,0 +1,20 @@
--- src/util.c.orig Fri Oct 25 11:27:19 2002
+++ src/util.c Fri Oct 25 11:28:18 2002
@@ -132,7 +132,7 @@
static void
ReapChild()
{
-#if defined(WNOHANG) && !defined(SYSV) && !defined(SVR4)
+#if defined(WNOHANG) && !defined(SYSV) && !defined(SVR4) && !defined(__FreeBSD__)
int pid;
#endif
extern int errno;
@@ -142,7 +142,7 @@
* It would probably be better to use the POSIX mechanism here,but I have not
* checked into it. This gets us off the ground with SYSV. RSE@GMI
*/
-#if defined(WNOHANG) && !defined(SYSV) && !defined(SVR4)
+#if defined(WNOHANG) && !defined(SYSV) && !defined(SVR4) && !defined(__FreeBSD__)
union wait st;
do

View File

@ -0,0 +1,11 @@
--- action.c.orig Fri Oct 25 11:18:06 2002
+++ action.c Fri Oct 25 11:18:39 2002
@@ -178,7 +178,7 @@
{
int pid;
int i = 0;
- union wait status;
+ int status;
/*

View File

@ -0,0 +1,20 @@
--- appman.c.orig Thu Mar 14 08:02:00 1996
+++ appman.c Fri Oct 25 11:12:39 2002
@@ -1297,7 +1297,7 @@
#endif
FILE *processfp = NULL; /* file pointer to process */
String *newargs, args;
-#if !defined(SYSV) && !defined(SVR4_0) && !defined(_POSIX_SOURCE) && !defined(__386BSD__)
+#if !defined(SYSV) && !defined(SVR4_0) && !defined(_POSIX_SOURCE) && !defined(__386BSD__) && !defined(__FreeBSD__)
union wait w_stat; /* I'm not sure about the SYSV bit... */
#else
int w_stat;
@@ -1843,7 +1843,7 @@
extern String cwd;
int pid;
-#if !defined(SYSV) && !defined(SVR4_0) && !defined(_POSIX_SOURCE)
+#if !defined(SYSV) && !defined(SVR4_0) && !defined(_POSIX_SOURCE) && !defined(__FreeBSD__)
union wait status;
#else
int status;