This is the mail archive of the cygwin mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

RE: Cygwin IPC - ftok() returns negative values - Bug Report


>On 29/06/2016 18:06, StanisÅaw Wawszczak wrote:
>> Dear Corinna,
>>
>> I am sorry about confusing you.
>> Simply:
>>
>> ----------------------------- Issue 
>> ------------------------------------
>> Call to ftok() returns negative value
>
> Hi StanisÅaw,
>
> may be I am missing somthing, but nothing on http://pubs.opengroup.org/onlinepubs/9699919799/functions/ftok.html
> 
> suggest me that the return value must be positive

Hi Marco,

You are absolutely right. But all code examples, what I have seen including sblim-sfcbd (what I have to compile) is testing result from ftok() as positive value.
The case-test code is working on native linux with positive value returned from ftok().

I have made some tests and I have stated that making call to getsem() on Cygwin with nsems == 1 is working with negative key returned from ftok.

So this is not my case at all. I am really sorry about wrong question. 

*Real question is why Cygwin's implementation of getsem() is not allowing to ask for more than nsems == 1?*
Here is stated, that the platform is limiting the nsems value: http://pubs.opengroup.org/onlinepubs/9699919799/functions/semget.html#tag_16_512
This code is not working, return errno == 22 (EINVAL, I guess...)
#include <sys/ipc.h>
#include <sys/sem.h>
#include <stdio.h>
#include <errno.h>

int main(int argc, char**argv)
{
	int provs = 100;
	key_t semHandle = ftok("/etc/fstab", 'A');
	int sfcbSem = -1;
	printf("semHandle <= 0 ; (semHandle = %lld)\n", semHandle);
	if ((sfcbSem = semget(semHandle, 2, IPC_CREAT | IPC_EXCL | 0600)) == -1)
	{
		printf("error semget, errno = %d\n", errno);
	}
	printf("finished\n");
	return 0;
}

> Regards
> Marco


--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]