This is the mail archive of the
cygwin
mailing list for the Cygwin project.
RE: Cygwin IPC - ftok() returns negative values - Bug Report
- From: StanisÅaw Wawszczak <stanislaw dot wawszczak at iscg dot pl>
- To: Marco Atzeri <marco dot atzeri at gmail dot com>, "cygwin at cygwin dot com" <cygwin at cygwin dot com>
- Date: Wed, 29 Jun 2016 19:20:38 +0000
- Subject: RE: Cygwin IPC - ftok() returns negative values - Bug Report
- Authentication-results: sourceware.org; auth=none
- Authentication-results: spf=none (sender IP is ) smtp dot mailfrom=stanislaw dot wawszczak at iscg dot pl;
- References: <AM3PR05MB3399758BC225C8E63BACF0FEB230 at AM3PR05MB339 dot eurprd05 dot prod dot outlook dot com> <20160629151446 dot GO981 at calimero dot vinschen dot de> <DB3PR05MB3481DD1143D413B28B2EF1BEB230 at DB3PR05MB348 dot eurprd05 dot prod dot outlook dot com> <f067d528-3262-ab8a-0681-a4f55ab5c365 at gmail dot com>
- Spamdiagnosticmetadata: NSPM
- Spamdiagnosticoutput: 1:99
>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