Mail Archives: cygwin/2004/08/12/08:03:51
--=-SEf6iT+Q4o7jBrHekyab
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
Le jeu 12/08/2004 =C3=A0 12:44, Corinna Vinschen a =C3=A9crit :
> On Aug 12 12:13, bertrand marquis wrote:
> > In fact i wasn't using the SHM_RNd flag.
> >=20
> > In details here is what i do:
> >=20
> > - get a shared segment of with size=3D 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=3D
> > beginaddress + SIZE
> >=20
> > without SHM_RND in the second shmat i've got the error : invalid
> > argument
> >=20
> > now that i specifie SHM_RND in the flag i have the error: value to large
> > for defined type ....
> >=20
> > any idea ?
>=20
> 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.
>=20
>=20
> 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
--=-SEf6iT+Q4o7jBrHekyab
Content-Disposition: attachment; filename=testshm.c
Content-Type: text/x-c; name=testshm.c; charset=UTF-8
Content-Transfer-Encoding: 7bit
#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));
}
}
--=-SEf6iT+Q4o7jBrHekyab
Content-Type: text/plain; charset=us-ascii
--
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/
--=-SEf6iT+Q4o7jBrHekyab--
- Raw text -