Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 8 Feb 2004 21:25:21 +0800
From:      "airsupply" <airsupply@freebsdchina.org>
To:        freebsd-hackers@freebsd.org <freebsd-hackers@freebsd.org>
Subject:   Re: shmat  help
Message-ID:  <20040208132622.3325543D1F@mx1.FreeBSD.org>

next in thread | raw e-mail | index | archive | help
airsupply,=C4=FA=BA=C3=A3=A1

=09oh,i have get it. it's code error.

=3D=3D=3D=3D=3D=3D=3D 2004-02-07 23:37:00 =C4=FA=D4=DA=C0=B4=D0=C5=D6=D0=D0=B4=B5=C0=A3=BA=3D=3D=3D=3D=3D=3D=3D

>freebsd-hackers=A3=AC=C4=FA=BA=C3=A3=A1
>
>=09                  
>i am test shmat under freebsd 4.8 release(without undate),but a=
 piece of simple code wont work.
>code like this:
>#include<stdio.h>
>#include<machine/param.h>
>#include<sys/types.h>
>#include<sys/ipc.h>
>#include<sys/shm.h>
>#include <unistd.h>
>
>#define SHM_KEY 100
>#define SHM_SIZE 1024
>int main(int argc,char *argv[])
>{
>        int shmid;
>        void *shmaddr1,*shmaddr2,*shmaddr3;
>        if(shmid=3Dshmget(SHM_KEY,SHM_SIZE,IPC_CREAT|0660)=3D=3D-1)
>        {
>                perror("shmget");
>                exit(-1);
>        }
>
>        printf("shmid: d\n",shmid);
>        if(shmaddr1=3Dshmat(shmid,0,0)=3D=3D-1)
>        {
>                perror("shmat 1");
>                exit(-1);
>        }
>        printf("shaddr1:0x.8x\n",shmaddr1);
>
>        if(shmaddr2=3Dshmat(shmid,0,0)=3D=3D-1)
>        {
>                perror("shmat 2");
>                exit(-1);
>        }
>        printf("shaddr2:0x.8x\n",shmaddr2);
>        while(1);
>        return 0;
>}
>
>then i get error like this:
>
>shmid: 0
>shmat 1: Invalid argument
>then i use ipcs,find that the shmid is not 0,but an integer=
 number.
>-bash-2.05b$ ipcs
>Message Queues:
>T     ID     KEY        MODE       OWNER    GROUP
>
>Shared Memory:
>T     ID     KEY        MODE       OWNER    GROUP
>m  65536        100 --rw-rw-rw-     airs    wheel
>
>Semaphores:
>T     ID     KEY        MODE       OWNER    GROUP
>
>
>
>who can help me? who i can't use the shmid at shmat(shmid,0,0) ?=
  
>
>
>=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=D6=C2
>=C0=F1=A3=A1
> =09=09=09=09
>
>=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1airsupply
>=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1airsupply@freebsdchina.org
>=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A12004-02-07
>
>
>_______________________________________________
>freebsd-hackers@freebsd.org mailing list
>http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
>To unsubscribe, send any mail to=
 "freebsd-hackers-unsubscribe@freebsd.org"

=3D =3D =3D =3D =3D =3D =3D =3D =3D =3D =3D =3D =3D =3D =3D =3D =3D =3D =3D =3D
=09=09=09

=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=D6=C2
=C0=F1=A3=A1
 
=09=09=09=09 
=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1airsupply
=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1airsupply@freebsdchina.org
=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A12004-02-08





Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20040208132622.3325543D1F>