Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit7e16f3c

Browse files
committed
PostgreSQL works again on Mac OS X 10.1. Hold your nose before
investigating the kluge that makes it so...
1 parent64af43a commit7e16f3c

File tree

3 files changed

+136
-2
lines changed

3 files changed

+136
-2
lines changed

‎src/backend/port/darwin/Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,15 @@
44
# Makefile for port/darwin
55
#
66
# IDENTIFICATION
7-
# $Header: /cvsroot/pgsql/src/backend/port/darwin/Makefile,v 1.1 2000/12/11 00:49:54 tgl Exp $
7+
# $Header: /cvsroot/pgsql/src/backend/port/darwin/Makefile,v 1.2 2001/11/08 04:24:03 tgl Exp $
88
#
99
#-------------------------------------------------------------------------
1010

1111
subdir = src/backend/port/darwin
1212
top_builddir = ../../../..
1313
include$(top_builddir)/src/Makefile.global
1414

15-
OBJS = sem.o
15+
OBJS = sem.o system.o
1616

1717
all: SUBSYS.o
1818

‎src/backend/port/darwin/README

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
The file system.c included herein is taken directly from Apple's Darwin
2+
open-source CVS archives, and is redistributed under the BSD copyright
3+
notice it bears. (According to Apple's CVS logs, their version is
4+
identical to the FreeBSD original.) It provides our own implementation of
5+
the system(3) function, which ought by all rights to be identical to the
6+
one provided in libc on Darwin machines. Nonetheless, this version works,
7+
whereas the one that actually ships with Mac OS X 10.1 doesn't. The
8+
shipped version appears to disconnect the calling process from any shared
9+
memory segments it is attached to. (The symptom seen in PostgreSQL is
10+
that a backend attempting to execute CREATE DATABASE core-dumps.) I would
11+
love to know why there is a discrepancy between the published source and
12+
the actual behavior --- tgl 7-Nov-2001.
13+
14+
Appropriate bug reports have been filed with Apple --- see
15+
Radar Bug#s 2767956, 2683531, 2805147. One hopes we can retire this
16+
kluge in the not too distant future.
17+
18+
19+
As of PostgreSQL 7.2 and Mac OS X 10.1, one should expect warnings
20+
like these while linking the backend:
21+
22+
/usr/bin/ld: warning unused multiple definitions of symbol _system
23+
port/SUBSYS.o definition of _system in section (__TEXT,__text)
24+
/usr/lib/libm.dylib(system.o) unused definition of _system
25+
/usr/bin/ld: warning unused multiple definitions of symbol _semctl
26+
port/SUBSYS.o definition of _semctl in section (__TEXT,__text)
27+
/usr/lib/libm.dylib(semctl.o) unused definition of _semctl
28+
/usr/bin/ld: warning unused multiple definitions of symbol _semget
29+
port/SUBSYS.o definition of _semget in section (__TEXT,__text)
30+
/usr/lib/libm.dylib(semget.o) unused definition of _semget
31+
/usr/bin/ld: warning unused multiple definitions of symbol _semop
32+
port/SUBSYS.o definition of _semop in section (__TEXT,__text)
33+
/usr/lib/libm.dylib(semop.o) unused definition of _semop
34+
35+
The first of these shows us overriding system() per the above-described
36+
hack. The rest show sem.c overriding the nonfunctional semaphore stubs
37+
in libc. (Perhaps sem.c can also be retired someday, but semget support
38+
is reportedly not high on Apple's to-do list.)

‎src/backend/port/darwin/system.c

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
/*
2+
* Copyright (c) 1988, 1993
3+
*The Regents of the University of California. All rights reserved.
4+
*
5+
* Redistribution and use in source and binary forms, with or without
6+
* modification, are permitted provided that the following conditions
7+
* are met:
8+
* 1. Redistributions of source code must retain the above copyright
9+
* notice, this list of conditions and the following disclaimer.
10+
* 2. Redistributions in binary form must reproduce the above copyright
11+
* notice, this list of conditions and the following disclaimer in the
12+
* documentation and/or other materials provided with the distribution.
13+
* 3. All advertising materials mentioning features or use of this software
14+
* must display the following acknowledgement:
15+
*This product includes software developed by the University of
16+
*California, Berkeley and its contributors.
17+
* 4. Neither the name of the University nor the names of its contributors
18+
* may be used to endorse or promote products derived from this software
19+
* without specific prior written permission.
20+
*
21+
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
22+
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23+
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24+
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
25+
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26+
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27+
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28+
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29+
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30+
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31+
* SUCH DAMAGE.
32+
*
33+
* $FreeBSD: src/lib/libc/stdlib/system.c,v 1.6 2000/03/16 02:14:41 jasone Exp $
34+
*/
35+
36+
#if defined(LIBC_SCCS)&& !defined(lint)
37+
staticcharsccsid[]="@(#)system.c8.1 (Berkeley) 6/4/93";
38+
#endif/* LIBC_SCCS and not lint */
39+
40+
#include<sys/types.h>
41+
#include<sys/wait.h>
42+
#include<signal.h>
43+
#include<stdlib.h>
44+
#include<stddef.h>
45+
#include<unistd.h>
46+
#include<paths.h>
47+
#include<errno.h>
48+
49+
intsystem(constchar*command);
50+
51+
int
52+
system(constchar*command)
53+
{
54+
pid_tpid;
55+
intpstat;
56+
structsigactionign,intact,quitact;
57+
sigset_tnewsigblock,oldsigblock;
58+
59+
if (!command)/* just checking... */
60+
return(1);
61+
62+
/*
63+
* Ignore SIGINT and SIGQUIT, block SIGCHLD. Remember to save
64+
* existing signal dispositions.
65+
*/
66+
ign.sa_handler=SIG_IGN;
67+
(void)sigemptyset(&ign.sa_mask);
68+
ign.sa_flags=0;
69+
(void)sigaction(SIGINT,&ign,&intact);
70+
(void)sigaction(SIGQUIT,&ign,&quitact);
71+
(void)sigemptyset(&newsigblock);
72+
(void)sigaddset(&newsigblock,SIGCHLD);
73+
(void)sigprocmask(SIG_BLOCK,&newsigblock,&oldsigblock);
74+
switch(pid=fork()) {
75+
case-1:/* error */
76+
break;
77+
case0:/* child */
78+
/*
79+
* Restore original signal dispositions and exec the command.
80+
*/
81+
(void)sigaction(SIGINT,&intact,NULL);
82+
(void)sigaction(SIGQUIT,&quitact,NULL);
83+
(void)sigprocmask(SIG_SETMASK,&oldsigblock,NULL);
84+
execl(_PATH_BSHELL,"sh","-c",command, (char*)NULL);
85+
_exit(127);
86+
default:/* parent */
87+
do {
88+
pid=wait4(pid,&pstat,0, (structrusage*)0);
89+
}while (pid==-1&&errno==EINTR);
90+
break;
91+
}
92+
(void)sigaction(SIGINT,&intact,NULL);
93+
(void)sigaction(SIGQUIT,&quitact,NULL);
94+
(void)sigprocmask(SIG_SETMASK,&oldsigblock,NULL);
95+
return(pid==-1 ?-1 :pstat);
96+
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp