public inbox for cygwin@cygwin.com
 help / color / mirror / Atom feed
* [ERROR] msgget() "Function not implmented" Error : Cygwin
@ 2023-02-28 10:13 Yeo Kai Wei
  2023-02-28 10:29 ` Corinna Vinschen
  0 siblings, 1 reply; 5+ messages in thread
From: Yeo Kai Wei @ 2023-02-28 10:13 UTC (permalink / raw)
  To: cygwin

[-- Attachment #1: Type: text/plain, Size: 452 bytes --]

Hi Cygwin,

May I ask if there will be an implementation of msgget() on Cygwin for 
Windows?

$ gcc -o sender sender.c

$ ./sender
key is 62720123
qid is -1
couldn't get queue id: Function not implemented

I googled the above error and it seems like this issue was raised in 2017.

It was meant to be fixed but I seem to have the same problem.

May I ask what I should do?

I've attached the files that I used.

Thank you.


Kind Regards,

YEO Kai Wei

[-- Attachment #2: sender.c --]
[-- Type: text/plain, Size: 1070 bytes --]

#include <stdio.h>

#include <sys/ipc.h> //ftok(). File-to-key?

#include <sys/msg.h> //msgget

#include <stdlib.h>

#include <string.h>

#include "queue.h"

void report_and_exit(const char* msg)
{
	perror(msg);

	exit(-1);
}


int main()
{
	key_t key = ftok(PATHNAME, PROJECTID);

	if(key<0)
		report_and_exit("couldn't get key...");

	printf("key is %i\n", key);

	//msgget() creates message queue
	//Returns System V message qid associated with value of key argument.
	int qid = msgget(key, 0666 | IPC_CREAT);
	
	printf("qid is %i\n", qid);

	//Ran into error here
	if(qid<0)
		report_and_exit("couldn't get queue id");


	char* payloads[] = {"msg1","msg2","msg3","msg4","msg5","msg6"};

	int types[] = {1,1,2,2,3,3};

	int i;

	for( i = 0; i< MESSAGECOUNT ; i++)
	{
		//Type from queue.h
		queuedMessage msg;

		msg.type = types[i];

		strcpy(msg.payload, payloads[i]);

		msgsnd(qid,&msg,MESSAGELENGTH + 1, IPC_NOWAIT);

		printf("%s sent as type %i\n", msg.payload, (int) msg.type);
	}

	return 0;
}


[-- Attachment #3: queue.h --]
[-- Type: text/plain, Size: 241 bytes --]

#define PROJECTID 123

#define PATHNAME "queue.h"

#define MESSAGELENGTH 4

#define MESSAGECOUNT 6


typedef struct 
{
	long type;	//message type

	char payload[MESSAGELENGTH + 1]; //message. Some text.

} queuedMessage;



[-- Attachment #4: receiver.c --]
[-- Type: text/plain, Size: 1077 bytes --]

#include <stdio.h>

#include <sys/ipc.h> //ftok() convert pathname + ProjecID to System V IPC key

#include <sys/msg.h>

#include <stdlib.h>

#include "queue.h"

void report_and_exit(const char* msg)
{
	perror(msg);

	exit(-1);
}


int main()
{
	//Sys V IPC key
	key_t key = ftok(PATHNAME, PROJECTID);

	printf("key is %i\n", key);

	if(key<0)
		report_and_exit("key not gotten");

	//Create if needed, otherwise access. Not create again.
	int qid = msgget(key, 0666 | IPC_CREAT);

	if(qid < 0)
		report_and_exit("no access to queue...");

	//Different from sender.c
	int types[] = {3,1,2,1,3,2};

	int i;

	//Sender.c uses msgsend(). Receiver.c uses msgrcv()
	for(i=0; i < MESSAGECOUNT ; i++)
	{
		queuedMessage msg;

		if(msgrcv(qid,&msg, MESSAGELENGTH + 1, types[i], MSG_NOERROR | IPC_NOWAIT) < 0)
			puts("msgrcv trouble...");

		printf("%s received as type %i\n", msg.payload, (int) msg.type);
	}	

	//Remove the q
	if(msgctl(qid, IPC_RMID, NULL) < 0)
		report_and_exit("trouble removing queue...");

	return 0;
}


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [ERROR] msgget() "Function not implmented" Error : Cygwin
  2023-02-28 10:13 [ERROR] msgget() "Function not implmented" Error : Cygwin Yeo Kai Wei
@ 2023-02-28 10:29 ` Corinna Vinschen
  2023-03-01 11:56   ` Yeo Kai Wei
  2023-03-05 16:35   ` [ERROR] msgget() "Function not implemented" " Yeo Kai Wei
  0 siblings, 2 replies; 5+ messages in thread
From: Corinna Vinschen @ 2023-02-28 10:29 UTC (permalink / raw)
  To: Yeo Kai Wei; +Cc: cygwin

On Feb 28 18:13, Yeo Kai Wei via Cygwin wrote:
> Hi Cygwin,
> 
> May I ask if there will be an implementation of msgget() on Cygwin for
> Windows?

There is, for ages.  However, you have to run cygserver for that
to work:

  https://cygwin.com/cygwin-ug-net/using-cygserver.html

If cygserver isn't running, the XSI IPC functions return ENOSYS.

Alternatively, convert your tool to using POSIX message queues, those
are using a file backed solution and don't require cygserver.


Corinna

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [ERROR] msgget() "Function not implmented" Error : Cygwin
  2023-02-28 10:29 ` Corinna Vinschen
@ 2023-03-01 11:56   ` Yeo Kai Wei
  2023-03-01 18:36     ` Ken Brown
  2023-03-05 16:35   ` [ERROR] msgget() "Function not implemented" " Yeo Kai Wei
  1 sibling, 1 reply; 5+ messages in thread
From: Yeo Kai Wei @ 2023-03-01 11:56 UTC (permalink / raw)
  To: cygwin

[-- Attachment #1: Type: text/plain, Size: 2419 bytes --]

Hi Corinna,

Thank you for the help.

I tried following the instructions on 
https://cygwin.com/cygwin-ug-net/using-cygserver.html#start-cygserver

There was a line, "Before you run Cygserver for the first time, you 
should run the /usr/bin/cygserver-config script once."

I googled for some instructions and it said to use "cygserver-config" in 
the Cygwin terminal.

I did it and the following is the reply from the terminal.

*Without admin privileges*

"$ cygserver-config
Generating /etc/cygserver.conf file
chown: changing ownership of '/etc/cygserver.conf': Permission denied


Warning: The following function requires administrator privileges!

Do you want to install cygserver as service?
(Say "no" if it's already installed as service) (yes/no) yes
/usr/bin/cygserver-config: line 181: cygrunsrv: command not found

Installation of cygserver as service failed.  Please check the
error messages you got.  They might give a clue why it failed.

A good start is either you don't have administrator privileges
or a missing cygrunsrv binary.  Please check for both."


*With admin privileges*
"$ cygserver-config
Overwrite existing /etc/cygserver.conf file? (yes/no) yes
Generating /etc/cygserver.conf file


Warning: The following function requires administrator privileges!

Do you want to install cygserver as service?
(Say "no" if it's already installed as service) (yes/no) yes
/usr/bin/cygserver-config: line 181: cygrunsrv: command not found

Installation of cygserver as service failed.  Please check the
error messages you got.  They might give a clue why it failed.

A good start is either you don't have administrator privileges
or a missing cygrunsrv binary.  Please check for both."


May I ask what I should do next?


Thank you very much.


Kind Regards,

YEO Kai Wei

P.S. How do you convert to using POSIX message queues in Cygwin?


On 28/2/2023 6:29 pm, Corinna Vinschen wrote:
> On Feb 28 18:13, Yeo Kai Wei via Cygwin wrote:
>> Hi Cygwin,
>>
>> May I ask if there will be an implementation of msgget() on Cygwin for
>> Windows?
> There is, for ages.  However, you have to run cygserver for that
> to work:
>
>    https://cygwin.com/cygwin-ug-net/using-cygserver.html
>
> If cygserver isn't running, the XSI IPC functions return ENOSYS.
>
> Alternatively, convert your tool to using POSIX message queues, those
> are using a file backed solution and don't require cygserver.
>
>
> Corinna

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [ERROR] msgget() "Function not implmented" Error : Cygwin
  2023-03-01 11:56   ` Yeo Kai Wei
@ 2023-03-01 18:36     ` Ken Brown
  0 siblings, 0 replies; 5+ messages in thread
From: Ken Brown @ 2023-03-01 18:36 UTC (permalink / raw)
  To: cygwin

[Please don't top-post.]

On 3/1/2023 6:56 AM, Yeo Kai Wei via Cygwin wrote:
> Do you want to install cygserver as service?
> (Say "no" if it's already installed as service) (yes/no) yes
> /usr/bin/cygserver-config: line 181: cygrunsrv: command not found
> 
> Installation of cygserver as service failed.  Please check the
> error messages you got.  They might give a clue why it failed.
> 
> A good start is either you don't have administrator privileges
> or a missing cygrunsrv binary.  Please check for both."
> 
> 
> May I ask what I should do next?

Did you check for the cygrunsrv binary?  If you don't have it, then 
install the cygrunsrv package.

Ken

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [ERROR] msgget() "Function not implemented" Error : Cygwin
  2023-02-28 10:29 ` Corinna Vinschen
  2023-03-01 11:56   ` Yeo Kai Wei
@ 2023-03-05 16:35   ` Yeo Kai Wei
  1 sibling, 0 replies; 5+ messages in thread
From: Yeo Kai Wei @ 2023-03-05 16:35 UTC (permalink / raw)
  To: cygwin

[-- Attachment #1: Type: text/plain, Size: 1175 bytes --]

How To Deal With the msgget() Issue and "Function not implemented" and 
Cygwin Server

1. Download the "*cygrunsrv*" binaries using "setup-x86_64.exe". Search 
for it at the DLL page. Download 1.64-1. Now you have Cygwin Server. 
This is usually not mentioned.

2. Run Cygwin as administrator. This is usually not mentioned.

3. Start the Cygwin server with "*net start cygserver*". It should say 
"The CYGWIN cygserver service is starting.
The CYGWIN cygserver service was started successfully.". You have to 
google this. It is not on the instruction page for some reason.

4. Run the program. It should work now.


On 28/2/2023 6:29 pm, Corinna Vinschen wrote:
> On Feb 28 18:13, Yeo Kai Wei via Cygwin wrote:
>> Hi Cygwin,
>>
>> May I ask if there will be an implementation of msgget() on Cygwin for
>> Windows?
> There is, for ages.  However, you have to run cygserver for that
> to work:
>
>    https://cygwin.com/cygwin-ug-net/using-cygserver.html
>
> If cygserver isn't running, the XSI IPC functions return ENOSYS.
>
> Alternatively, convert your tool to using POSIX message queues, those
> are using a file backed solution and don't require cygserver.
>
>
> Corinna

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2023-03-05 16:35 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-02-28 10:13 [ERROR] msgget() "Function not implmented" Error : Cygwin Yeo Kai Wei
2023-02-28 10:29 ` Corinna Vinschen
2023-03-01 11:56   ` Yeo Kai Wei
2023-03-01 18:36     ` Ken Brown
2023-03-05 16:35   ` [ERROR] msgget() "Function not implemented" " Yeo Kai Wei

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).