Hi Matthew, On Sun, 12 Mar 2023 at 07:44, Matthew Rickard wrote: > > Hi all, > > Cygwin 3.4.6-1 shm_open seems to reject all calls, returning the value > -1 and setting errno to 22 EINVAL. > > For example, this program: > > #include <sys/mman.h> > #include <fcntl.h> > #include <errno.h> > #include <stdio.h> > > int main() { > int res = shm_open("123", O_CREAT | O_RDWR, 0666); > int error = errno; > printf("res=%d errno=%d\n", res, errno); > if (error == EINVAL) > printf("That's EINVAL\n"); > return 0; > } > > Says: > > $ gcc -Og -o tiny tiny.c; ./tiny > res=-1 errno=22 > That's EINVAL >
https://man7.org/linux/man-pages/man3/shm_open.3.html says: For portable use, a shared memory object should be identified by a name of the form /somename; that is, a null-terminated string of up to NAME_MAX (i.e., 255) characters consisting of an initial slash, followed by one or more characters, none of which are slashes. Changing the shm_open call to shm_open("/123", O_CREAT | O_RDWR, 0666); returns 3 and sets errno to zero. Csaba -- You can get very substantial performance improvements by not doing the right thing. - Scott Meyers, An Effective C++11/14 Sampler So if you're looking for a completely portable, 100% standards-conformant way to get the wrong information: this is what you want. - Scott Meyers (C++TDaWYK) -- Problem reports: https://cygwin.com/problems.html FAQ: https://cygwin.com/faq/ Documentation: https://cygwin.com/docs.html Unsubscribe info: https://cygwin.com/ml/#unsubscribe-simple