work in BeOS port.
* shm.c
* BeOS System V Shared Memory Emulation
*
- * Copyright (c) 1999-2000, Cyril VELTER
+ * Copyright (c) 1999-2001, Cyril VELTER
*
*-------------------------------------------------------------------------
*/
#include "postgres.h"
#include <stdio.h>
#include <OS.h>
+#include <errno.h>
/* Emulating SYS shared memory with beos areas. WARNING : fork clone
areas in copy on write mode */
}
if (flag == IPC_STAT)
{
- /* Is there a way to check existence of an area given its ID?
- * For now, punt and assume it does not exist.
- */
- errno = EINVAL;
- return -1;
+ /* Find any SYSV area with the shmid in its name */
+
+ area_info inf;
+ team_info infteam;
+ int32 cookteam=0;
+ char name[50];
+ sprintf(name,"SYSV_IPC %d",shmid);
+
+ dummy->shm_nattch=0;
+
+ while (get_next_team_info(&cookteam, &infteam) == B_OK)
+ {
+ int32 cook=0;
+ while (get_next_area_info(infteam.team, &cook, &inf) == B_OK)
+ {
+ if (strcmp(name,inf.name) == 0)
+ {
+ dummy->shm_nattch++;
+ }
+ }
+ }
+
+ errno = 0;
+ return 0;
}
errno = EINVAL;
return -1;
* support.c
* BeOS Support functions
*
- * Copyright (c) 1999-2000, Cyril VELTER
+ * Copyright (c) 1999-2001, Cyril VELTER
*
*-------------------------------------------------------------------------
*/
delete_area(inf.area);
/* Find the postmaster area */
area_postmaster=find_area(inf.name);
+ /* Compute new area name */
+ sprintf(nvnom,"SYSV_IPC %d",area_postmaster);
/* Clone it at the exact same address */
clone_area(nvnom,&area_address,B_CLONE_ADDRESS,B_READ_AREA|B_WRITE_AREA,area_postmaster);
}
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/utils/init/miscinit.c,v 1.62 2001/03/13 01:17:06 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/utils/init/miscinit.c,v 1.63 2001/03/18 18:22:08 tgl Exp $
*
*-------------------------------------------------------------------------
*/
/*
* Check to see if the other process still exists
+ *
+ * Normally kill() will fail with ESRCH if the given PID doesn't
+ * exist. BeOS returns EINVAL for some silly reason, however.
*/
if (other_pid != my_pid)
{
if (kill(other_pid, 0) == 0 ||
- errno != ESRCH)
+ (errno != ESRCH
+#ifdef __BEOS__
+ && errno != EINVAL
+#endif
+ ))
{
/* lockfile belongs to a live process */
fprintf(stderr, "Lock file \"%s\" already exists.\n",
#define IPC_EXCL 1024
#define IPC_PRIVATE 234564
#define IPC_NOWAIT 2048
+#define IPC_STAT 4096
#define EACCESS 2048
#define EIDRM 4096
struct shmid_ds
{
int dummy;
+ int shm_nattch;
};
int semctl(int semId,int semNum,int flag,union semun);