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

Commite8f4385

Browse files
committed
pq/signal() portability patch. Also psql copy prompt fix.
1 parent7f00f11 commite8f4385

File tree

12 files changed

+67
-77
lines changed

12 files changed

+67
-77
lines changed

‎src/backend/bootstrap/bootstrap.c

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* Copyright (c) 1994, Regents of the University of California
88
*
99
* IDENTIFICATION
10-
* $Header: /cvsroot/pgsql/src/backend/bootstrap/bootstrap.c,v 1.12 1996/11/22 04:32:41 bryanh Exp $
10+
* $Header: /cvsroot/pgsql/src/backend/bootstrap/bootstrap.c,v 1.13 1996/12/26 22:06:59 momjian Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -33,6 +33,7 @@
3333
#include"access/skey.h"
3434
#include"access/strat.h"
3535
#include"utils/rel.h"
36+
#include"libpq/pqsignal.h"
3637

3738
#include"storage/block.h"
3839
#include"storage/off.h"
@@ -291,10 +292,10 @@ BootstrapMain(int argc, char *argv[])
291292
* initialize signal handlers
292293
* ----------------
293294
*/
294-
signal(SIGINT, (sig_func)die);
295+
pqsignal(SIGINT, (sig_func)die);
295296
#ifndefwin32
296-
signal(SIGHUP, (sig_func)die);
297-
signal(SIGTERM, (sig_func)die);
297+
pqsignal(SIGHUP, (sig_func)die);
298+
pqsignal(SIGTERM, (sig_func)die);
298299
#endif/* win32 */
299300

300301
/* --------------------
@@ -406,7 +407,7 @@ BootstrapMain(int argc, char *argv[])
406407
* ----------------
407408
*/
408409
#ifndefwin32
409-
signal(SIGHUP,handle_warn);
410+
pqsignal(SIGHUP,handle_warn);
410411

411412
if (sigsetjmp(Warn_restart,1)!=0) {
412413
#else

‎src/backend/libpq/pqcomm.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*
88
*
99
* IDENTIFICATION
10-
* $Header: /cvsroot/pgsql/src/backend/libpq/pqcomm.c,v 1.9 1996/11/24 04:05:20 bryanh Exp $
10+
* $Header: /cvsroot/pgsql/src/backend/libpq/pqcomm.c,v 1.10 1996/12/26 22:07:03 momjian Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -36,6 +36,7 @@
3636
*/
3737
#include<stdio.h>
3838
#include<string.h>
39+
#include<signal.h>
3940
#include<errno.h>
4041
#include<fcntl.h>
4142
#ifndefWIN32
@@ -57,7 +58,7 @@
5758

5859
#include<postgres.h>
5960

60-
#include<libpq/pqsignal.h>/* substitute for <signal.h> */
61+
#include<libpq/pqsignal.h>
6162
#include<libpq/auth.h>
6263
#include<libpq/libpq.h>/* where the declarations go */
6364

@@ -496,15 +497,15 @@ pq_regoob(void (*fptr)())
496497
#else/* hpux */
497498
fcntl(fd,F_SETOWN,getpid());
498499
#endif/* hpux */
499-
(void)signal(SIGURG,fptr);
500+
(void)pqsignal(SIGURG,fptr);
500501
#endif/* WIN32 */
501502
}
502503

503504
void
504505
pq_unregoob()
505506
{
506507
#ifndefWIN32
507-
signal(SIGURG,SIG_DFL);
508+
pqsignal(SIGURG,SIG_DFL);
508509
#endif/* WIN32 */
509510
}
510511

‎src/backend/libpq/pqsignal.c

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $Header: /cvsroot/pgsql/src/backend/libpq/pqsignal.c,v 1.4 1996/11/18 02:25:09 bryanh Exp $
11+
* $Header: /cvsroot/pgsql/src/backend/libpq/pqsignal.c,v 1.5 1996/12/26 22:07:08 momjian Exp $
1212
*
1313
* NOTES
1414
*This shouldn't be in libpq, but the monitor and some other
@@ -39,12 +39,16 @@
3939
* ------------------------------------------------------------------------*/
4040
#include<postgres.h>
4141

42+
#include<signal.h>
43+
4244
#include<libpq/pqsignal.h>
4345

4446
pqsigfunc
4547
pqsignal(intsigno,pqsigfuncfunc)
4648
{
47-
#if defined(USE_POSIX_SIGNALS)
49+
#if !defined(USE_POSIX_SIGNALS)
50+
returnsignal(signo,func);
51+
#else
4852
structsigactionact,oact;
4953

5054
act.sa_handler=func;
@@ -56,8 +60,5 @@ pqsignal(int signo, pqsigfunc func)
5660
if (sigaction(signo,&act,&oact)<0)
5761
return(SIG_ERR);
5862
return(oact.sa_handler);
59-
#else/* !USE_POSIX_SIGNALS */
60-
Assert(0);
61-
return0;
6263
#endif/* !USE_POSIX_SIGNALS */
6364
}

‎src/backend/postmaster/postmaster.c

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
*
1111
*
1212
* IDENTIFICATION
13-
* $Header: /cvsroot/pgsql/src/backend/postmaster/postmaster.c,v 1.29 1996/12/2617:49:05 momjian Exp $
13+
* $Header: /cvsroot/pgsql/src/backend/postmaster/postmaster.c,v 1.30 1996/12/2622:07:17 momjian Exp $
1414
*
1515
* NOTES
1616
*
@@ -40,7 +40,7 @@
4040

4141
#include"postgres.h"
4242

43-
#include"libpq/pqsignal.h"/* substitute for<signal.h> */
43+
#include<signal.h>
4444
#include<string.h>
4545
#include<stdlib.h>
4646

@@ -73,6 +73,7 @@
7373
#include"libpq/libpq.h"
7474
#include"libpq/auth.h"
7575
#include"libpq/pqcomm.h"
76+
#include"libpq/pqsignal.h"
7677
#include"miscadmin.h"
7778
#include"version.h"
7879
#include"lib/dllist.h"
@@ -394,14 +395,14 @@ PostmasterMain(int argc, char *argv[])
394395
if (silentflag)
395396
pmdaemonize();
396397

397-
signal(SIGINT,pmdie);
398+
pqsignal(SIGINT,pmdie);
398399
#ifndefWIN32
399-
signal(SIGCHLD,reaper);
400-
signal(SIGTTIN,SIG_IGN);
401-
signal(SIGTTOU,SIG_IGN);
402-
signal(SIGHUP,pmdie);
403-
signal(SIGTERM,pmdie);
404-
signal(SIGCONT,dumpstatus);
400+
pqsignal(SIGCHLD,reaper);
401+
pqsignal(SIGTTIN,SIG_IGN);
402+
pqsignal(SIGTTOU,SIG_IGN);
403+
pqsignal(SIGHUP,pmdie);
404+
pqsignal(SIGTERM,pmdie);
405+
pqsignal(SIGCONT,dumpstatus);
405406
#endif/* WIN32 */
406407

407408

‎src/backend/storage/lmgr/proc.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*
88
*
99
* IDENTIFICATION
10-
* $Header: /cvsroot/pgsql/src/backend/storage/lmgr/proc.c,v 1.11 1996/11/2707:17:48 vadim Exp $
10+
* $Header: /cvsroot/pgsql/src/backend/storage/lmgr/proc.c,v 1.12 1996/12/26 22:07:28 momjian Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -46,7 +46,7 @@
4646
* This is so that we can support more backends. (system-wide semaphore
4747
* sets run out pretty fast.) -ay 4/95
4848
*
49-
* $Header: /cvsroot/pgsql/src/backend/storage/lmgr/proc.c,v 1.11 1996/11/2707:17:48 vadim Exp $
49+
* $Header: /cvsroot/pgsql/src/backend/storage/lmgr/proc.c,v 1.12 1996/12/26 22:07:28 momjian Exp $
5050
*/
5151
#include<sys/time.h>
5252
#ifndefWIN32
@@ -65,7 +65,7 @@
6565

6666
#include"postgres.h"
6767
#include"miscadmin.h"
68-
#include"libpq/pqsignal.h"/* substitute for <signal.h> */
68+
#include"libpq/pqsignal.h"
6969

7070
#include"access/xact.h"
7171
#include"utils/hsearch.h"
@@ -157,7 +157,7 @@ InitProcess(IPCKey key)
157157
* ------------------
158158
*/
159159
#ifndefWIN32
160-
signal(SIGALRM,HandleDeadLock);
160+
pqsignal(SIGALRM,HandleDeadLock);
161161
#endif/* WIN32 we'll have to figure out how to handle this later */
162162

163163
SpinAcquire(ProcStructLock);

‎src/backend/tcop/postgres.c

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,19 +7,19 @@
77
*
88
*
99
* IDENTIFICATION
10-
* $Header: /cvsroot/pgsql/src/backend/tcop/postgres.c,v 1.23 1996/12/07 04:39:06 momjian Exp $
10+
* $Header: /cvsroot/pgsql/src/backend/tcop/postgres.c,v 1.24 1996/12/26 22:07:40 momjian Exp $
1111
*
1212
* NOTES
1313
* this is the "main" module of the postgres backend and
1414
* hence the main module of the "traffic cop".
1515
*
1616
*-------------------------------------------------------------------------
1717
*/
18-
#include"libpq/pqsignal.h"/* substitute for <signal.h> */
1918

2019
#include<unistd.h>
2120
#include<stdio.h>
2221
#include<string.h>
22+
#include<signal.h>
2323
#include<time.h>
2424
#include<setjmp.h>
2525
#include<sys/time.h>
@@ -77,6 +77,7 @@
7777
#include"tcop/fastpath.h"
7878

7979
#include"libpq/libpq.h"
80+
#include"libpq/pqsignal.h"
8081
#include"rewrite/rewriteHandler.h"/* for QueryRewrite() */
8182

8283
/* ----------------
@@ -820,15 +821,15 @@ PostgresMain(int argc, char *argv[])
820821
* register signal handlers.
821822
* ----------------
822823
*/
823-
signal(SIGINT,die);
824+
pqsignal(SIGINT,die);
824825

825826
#ifndefWIN32
826-
signal(SIGHUP,die);
827-
signal(SIGTERM,die);
828-
signal(SIGPIPE,die);
829-
signal(SIGUSR1,quickdie);
830-
signal(SIGUSR2,Async_NotifyHandler);
831-
signal(SIGFPE,FloatExceptionHandler);
827+
pqsignal(SIGHUP,die);
828+
pqsignal(SIGTERM,die);
829+
pqsignal(SIGPIPE,die);
830+
pqsignal(SIGUSR1,quickdie);
831+
pqsignal(SIGUSR2,Async_NotifyHandler);
832+
pqsignal(SIGFPE,FloatExceptionHandler);
832833
#endif/* WIN32 */
833834

834835
/* --------------------
@@ -1246,7 +1247,7 @@ PostgresMain(int argc, char *argv[])
12461247
*/
12471248

12481249
#ifndefWIN32
1249-
signal(SIGHUP,handle_warn);
1250+
pqsignal(SIGHUP,handle_warn);
12501251

12511252
if (sigsetjmp(Warn_restart,1)!=0) {
12521253
#else
@@ -1271,7 +1272,7 @@ PostgresMain(int argc, char *argv[])
12711272
*/
12721273
if (IsUnderPostmaster== false) {
12731274
puts("\nPOSTGRES backend interactive interface");
1274-
puts("$Revision: 1.23 $ $Date: 1996/12/07 04:39:06 $");
1275+
puts("$Revision: 1.24 $ $Date: 1996/12/26 22:07:40 $");
12751276
}
12761277

12771278
/* ----------------

‎src/bin/psql/psql.c

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*
88
*
99
* IDENTIFICATION
10-
* $Header: /cvsroot/pgsql/src/bin/psql/Attic/psql.c,v 1.41 1996/12/2620:56:40 bryanh Exp $
10+
* $Header: /cvsroot/pgsql/src/bin/psql/Attic/psql.c,v 1.42 1996/12/2622:07:57 momjian Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -22,6 +22,7 @@
2222
#include<ctype.h>
2323
#include"postgres.h"
2424
#include"libpq-fe.h"
25+
#include"pqsignal.h"
2526
#include"stringutils.h"
2627
#include"psqlHelp.h"
2728
#ifdefNEED_STRDUP
@@ -513,19 +514,10 @@ SendQuery(bool * success_p, PsqlSettings * settings, const char *query,
513514
break;
514515
casePGRES_COPY_IN:
515516
*success_p= true;
516-
if (copy_in) {
517+
if (copy_in)
517518
handleCopyIn(results, false,copystream);
518-
}else {
519-
charc;
520-
/*
521-
* eat extra newline still in input buffer
522-
*
523-
*/
524-
fflush(stdin);
525-
if ((c=getc(stdin))!='\n'&&c!=EOF)
526-
(void)ungetc(c,stdin);
519+
else
527520
handleCopyIn(results, !settings->quiet,stdin);
528-
}
529521
break;
530522
casePGRES_NONFATAL_ERROR:
531523
casePGRES_FATAL_ERROR:
@@ -1676,15 +1668,18 @@ setFout(PsqlSettings * ps, char *fname)
16761668
else
16771669
fclose(ps->queryFout);
16781670
}
1679-
if (!fname)
1671+
if (!fname) {
16801672
ps->queryFout=stdout;
1673+
pqsignal(SIGPIPE,SIG_DFL);
1674+
}
16811675
else {
16821676
if (*fname=='|') {
1683-
signal(SIGPIPE,SIG_IGN);
1677+
pqsignal(SIGPIPE,SIG_IGN);
16841678
ps->queryFout=popen(fname+1,"w");
16851679
ps->pipe=1;
16861680
}else {
16871681
ps->queryFout=fopen(fname,"w");
1682+
pqsignal(SIGPIPE,SIG_DFL);
16881683
ps->pipe=0;
16891684
}
16901685
if (!ps->queryFout) {

‎src/include/config.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,8 +85,7 @@
8585
#if defined(dgux)
8686
# defineLINUX_ELF
8787
# defineNEED_UNION_SEMUN
88-
# define __USE_POSIX_SIGNALS
89-
# define-DUSE_POSIX_SIGNALS
88+
# define USE_POSIX_SIGNALS
9089
#endif
9190

9291
#if defined(hpux)

‎src/include/libpq/pqsignal.h

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
*
77
* Copyright (c) 1994, Regents of the University of California
88
*
9-
* $Id: pqsignal.h,v 1.4 1996/11/24 04:07:17 bryanh Exp $
9+
* $Id: pqsignal.h,v 1.5 1996/12/26 22:08:13 momjian Exp $
1010
*
1111
* NOTES
1212
* This shouldn't be in libpq, but the monitor and some other
@@ -17,14 +17,8 @@
1717
#ifndefPQSIGNAL_H
1818
#definePQSIGNAL_H
1919

20-
#include<signal.h>
21-
2220
typedefvoid (*pqsigfunc)(int);
2321

2422
externpqsigfuncpqsignal(intsigno,pqsigfuncfunc);
2523

26-
#if defined(USE_POSIX_SIGNALS)
27-
#definesignal(signo,handler)pqsignal(signo, (pqsigfunc)(handler))
28-
#endif/* USE_POSIX_SIGNALS */
29-
3024
#endif/* PQSIGNAL_H */

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp