public inbox for linux-ia64@vger.kernel.org
 help / color / mirror / Atom feed
From: Umut Aymakoglu <umuta@us.ibm.com>
To: linux-ia64@vger.kernel.org
Subject: shmat() ... is it a bug?
Date: Fri, 29 Aug 2003 00:04:10 +0000	[thread overview]
Message-ID: <marc-linux-ia64-106211685507764@msgid-missing> (raw)





Hi -
 Below ,I have 2 small programs which shows a problem in shmat() when the
executable linked with the curses library(libncurses). Has anybody seen
something like this?

a.c --> allocates a shared memory segment and attaches.
b.c --> attaching the allocated shared memory segment using the address
from a.c

thanks,
Umut


a.c:
-----
#include <stdio.h>
#include <sys/types.h>
#include <sys/shm.h>

main()
{

unsigned int segsize = 512*1024;
int                     shmid;
key_t               shmkey = 123456789;
void * adr;

shmid = shmget(shmkey, segsize,IPC_CREAT|0660);
adr = shmat(shmid, 0,0);

printf("shmid = %d  adr = %p\n",shmid, adr);
}


b.c:
-----
#include <stdio.h>
#include <stdlib.h>
#include<sys/types.h>
#include <sys/shm.h>

main(int argc, char **argv)
{
 void * addr1, * addr2;
key_t  shmkey = 123456789;
int shmid;

addr1 = (void*) strtoul(argv[1],NULL,0);
shmid = shmget(shmkey, 0, 0660);

addr2 = shmat(shmid, addr1, 0);
printf("addr2 = %p\n",addr2);
}

%gcc3 -o a a.c
%gcc3 -o b b.c
%gcc3 -o c b.c -lncurses

% ./a
shmid = 313556996 adr = 0x2000000000300000

%./b 0x2000000000300000
addr2 = 0x2000000000300000

%./c 0x2000000000300000
addr2 = 0xffffffffffffffff



             reply	other threads:[~2003-08-29  0:04 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-08-29  0:04 Umut Aymakoglu [this message]
2003-08-29  0:48 ` shmat() ... is it a bug? David Mosberger

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=marc-linux-ia64-106211685507764@msgid-missing \
    --to=umuta@us.ibm.com \
    --cc=linux-ia64@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox