0

I'm using package msys2/gcc in a 64-bit MSYS2 installation, under Windows 10 64-bit.

Sample C program:

#include <stdio.h>
#include <errno.h>
#include <sys/ipc.h>
#include <sys/shm.h>
#include <sys/stat.h>

int main(void)
{
    uint64_t key = ftok("shm.exe", 8);
    printf("%llx\n", key);
    int r = shmget(key, 1024, S_IRUSR|S_IWUSR|IPC_CREAT);
    if ( r == -1 )
        printf("FAIL %d\n", errno);
    else
        printf("OK\n");
}

When I run this from the MSYS2 shell I get FAIL 88 which is ENOSYS indicating that shmget is not implemented.

Is it possible to make the call work? The full program also uses semget and semop.

From googling it seems there is a lot of source code in MSYS2 related to SYSV IPC but perhaps something needs to be enabled somewhere.

M.M
  • 138,810
  • 21
  • 208
  • 365
  • MSYS2 is a shell environment emulating a lot of the POSIX and *nix stuff (like `fork()` for example). This is not to be confused with the MinGW GCC compiler toolchain which builds native Windows files (and doesn't have things like `fork()` and probably also not the SYSV IPC stuff). So in that respect MSYS2 is closer to Cygwin, both of which aren't really native Windows because they emulate POSIX/*nix stuff. So you're better off looking at Cygwin if you really need SYSV IPC functionality. – Brecht Sanders Jun 04 '20 at 15:39
  • @BrechtSanders unfortunately Cygwin is out for me due to [another issue](https://stackoverflow.com/questions/61812131/cygwin-64-bit-cannot-early-bind-to-dll-created-by-msvc-giving-cxa-atexit-err) – M.M Jun 04 '20 at 20:46
  • In my opinion you shouldn't mix environments (like linking between MinGW and MSVC libraries) and you should attempt to run things as native as possible. Unfortunately for this case this would involve replacing the shared memory stuff with Windows equivalents (see for example https://learn.microsoft.com/en-us/windows/win32/memory/creating-named-shared-memory) – Brecht Sanders Jun 04 '20 at 21:48
  • @BrechtSanders Yeah I don't see any way to avoid that sort of approach now – M.M Jun 04 '20 at 21:55

0 Answers0