shmget() returns xx if current user is not a administrator

patrick ficheux
Fri Oct 12 09:09:00 GMT 2007

In SANE (scanner project), the backend for snapscan failed to call 
shmget() with error EACCES (Permission denied) if the current user isn't 
When I'am logged as windows administrator, shmget() is called successfully

In both case, the env. variable CYGWIN exists and this value is 
cygserver is installed and runs

Is it possible to call shmget() without administrator's privileges ?
In this case, what kind of privileges a user must have ? and how to set 
those privileges ?


extract from snapscan backend

#ifndef SHM_R
#define SHM_R 0

#ifndef SHM_W
#define SHM_W 0

struct urb_counters_t {
    unsigned long read_urbs;
    unsigned long write_urbs;

static struct urb_counters_t* urb_counters = NULL;

static SANE_Status snapscani_usb_shm_init(void)
    unsigned int shm_size = sizeof(struct urb_counters_t);
    void* shm_area = NULL;
    int shm_id = shmget (IPC_PRIVATE, shm_size, IPC_CREAT | SHM_R | SHM_W);
    if (shm_id == -1)
        DBG ("snapscani_usb_shm_init: cannot create shared memory 
segment: %s\n",
            strerror (errno));
        return 1;

a log from strace
   92   19220 [main] testshmget 2944 shmget: shmget (key = 0, size = 8, 
shmflg = 0x200)
 1627   20847 [main] testshmget 2944 shmat: shmat (shmid = 327680, 
shmaddr = 0x0, shmflg = 0x0)
  732   21579 [main] testshmget 2944 shmat: -1 [13] = shmat ()
   65   21644 [main] testshmget 2944 __set_errno: void* shmat(int, const 
void*, int):224 val 13

Unsubscribe info:
Problem reports:

More information about the Cygwin mailing list