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: cygserver shmat


Le jeu 12/08/2004 Ã 12:44, Corinna Vinschen a Ãcrit :
> On Aug 12 12:13, bertrand marquis wrote:
> > In fact i wasn't using the SHM_RNd flag.
> > 
> > In details here is what i do:
> > 
> > - get a shared segment of with size= SIZE (SIZE multiple of SHMLBA)
> > - attach the segment without specifying address and storing the result
> > in beginaddress
> > - attach the segment again specifying the address: endposition=
> > beginaddress + SIZE
> > 
> > without SHM_RND in the second shmat i've got the error : invalid
> > argument
> > 
> > now that i specifie SHM_RND in the flag i have the error: value to large
> > for defined type ....
> > 
> > any idea ?
> 
> Nope.  Not without knowing the actual values.  An strace output of
> the affected calls would be good.  Even better, create a simple testcase
> which allows to reproduce the behaviour.  Just the minimum of necessary
> code.
> 
> 
> Corinna


Ok,

i have made a minimum program showing the problem.
You can try specifying or not SHM_RND in the second shmat, without i
have INvalid argument error and with i have value too large for defined
data type.


thanks
bertrand
#include <cygwin/shm.h>
#include <cygwin/ipc.h>
#include <stdio.h>
#include <errno.h>

#define SHM_R           0400
#define SHM_W           0200

main()
{
	int sh_key,sz;
	unsigned int size=1000000;
	unsigned char *begin,*end,*tmp;
	
	sz = getpagesize();
	size= (size / sz)*sz;

	sh_key = shmget (IPC_PRIVATE, size, IPC_CREAT | IPC_EXCL | SHM_R | SHM_W);
	if (sh_key != -1)
	{
		printf("sh_key=%i\n",sh_key);
		begin = (unsigned char *)shmat (sh_key, NULL, 0);
		
		if ( begin != -1)
		{
			tmp = begin + size;
			printf("begin=%d, tmp=%d\n",(int)begin,(int)tmp);
			
			end = (unsigned char *) shmat(sh_key,tmp,SHM_RND);
			
			if (tmp == end )
			{
				printf("end=%i\n",(int)end);
				
				shmdt(end);
			}
			else
			{
				printf("error in shmat : %s\n",strerror(errno));
			}
	
			shmdt(begin);
		}
		else
		{
			printf("error in shmat : %s\n",strerror(errno));
		}
		
		shmctl (sh_key, IPC_RMID, NULL);
	}
	else
	{
		printf("error in shmget : %s\n",strerror(errno));
	}

}

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

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