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,ÄúºÃ£¡
oh,i have get it. it's code error.
======= 2004-02-07 23:37:00 ÄúÔÚÀ´ÐÅÖÐдµÀ£º=======
>freebsd-hackers£¬ÄúºÃ£¡
>
>
>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=shmget(SHM_KEY,SHM_SIZE,IPC_CREAT|0660)==-1)
> {
> perror("shmget");
> exit(-1);
> }
>
> printf("shmid: d\n",shmid);
> if(shmaddr1=shmat(shmid,0,0)==-1)
> {
> perror("shmat 1");
> exit(-1);
> }
> printf("shaddr1:0x.8x\n",shmaddr1);
>
> if(shmaddr2=shmat(shmid,0,0)==-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) ?
>
>
>¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡ÖÂ
>Àñ£¡
>
>
>¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡airsupply
>¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡airsupply@freebsdchina.org
>¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡2004-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"
= = = = = = = = = = = = = = = = = = = =
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡ÖÂ
Àñ£¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡airsupply
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡airsupply@freebsdchina.org
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡2004-02-08
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20040208132622.3325543D1F>
