semget() API fails when run from CMD.exe but works from SH.exe

Steven Bardwell
Mon Dec 16 17:11:00 GMT 2013

OK -- I rewrote the test program using the POSIX IPC routine sem_open()
and the program runs in SH.exe (and mintty.exe) but gives this message 
when run from a DOS box:

Warning: '/dev/shm' does not exists or is not a directory.

POSIX semaphores require the existance of this directory.
Create the directory '/dev/shm' and set the permissions to 01777.
For instance on the command line: mkdir -m 01777 /dev/shm

On Dec 14 08:04, Steven Bardwell wrote:
> I would like my Cygwin programs to work from a DOS (CMD.exe) window, but I
> am
> having problems with some API calls. Here is a simple program that tries to
> create
> a semaphore – it works fine when it is run from sh.exe (or in a mintty
> window), but
> it crashes when run in a DOS window. (The Cygwin service is running.)
> Is there a way to make it work in both environments?

That's not the intention of the IPC calls.  They usually only work
if you set up a matching environment.

XSI IPC requires cygserver to run.  The XSI IPC structures are only kept
in memory and "something" has to keep them around and coordinate their
rather complex mechanics.  If cygserver isn't running, the XSI IPC calls
return ENOSYS.

If you need persistent semaphores, message queues or shared memory,
consider switching to POSIX IPC (sem_open, mq_open, shm_open and
friends).  They are backed by the filesystem, namely the Cygwin
directories /dev/mqueue and /dev/shm.  This makes them easier to work
with from a DOS shell.


Problem reports:
Unsubscribe info:

More information about the Cygwin mailing list