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
>[EMAIL PROTECTED]
> 2004-02-07
>
>
>_______________________________________________
>[EMAIL PROTECTED] mailing list
>http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
>To unsubscribe, send any mail to "[EMAIL PROTECTED]"
= = = = = = = = = = = = = = = = = = = =
致
礼!
airsupply
[EMAIL PROTECTED]
2004-02-08
_______________________________________________
[EMAIL PROTECTED] mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to "[EMAIL PROTECTED]"