Unix Programming - UNIX SystemV Shared Memory...

This is Interesting: Free IT Magazines  
Home > Archive > Unix Programming > June 2005 > UNIX SystemV Shared Memory...





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

Author UNIX SystemV Shared Memory...
Martin Vorbrodt

2005-06-14, 5:56 pm

Can I call shmat to attach to a shared memory segment after I called
shmctl(_id, IPC_RMID, 0) on it (marked it for destruction). I can't seam to
be able to do it under linux (fedora core 3). it that a standard behaviour?
can't find anything about it in the "man smhctl"

Thanx!


Dragan Cvetkovic

2005-06-14, 5:56 pm

"Martin Vorbrodt" <mvorbrodt@poczta.onet.pl> writes:

> Can I call shmat to attach to a shared memory segment after I called
> shmctl(_id, IPC_RMID, 0) on it (marked it for destruction). I can't seam to
> be able to do it under linux (fedora core 3). it that a standard behaviour?


It is. After all, after you delete a file, you can't open it, can you?

Dragan


--
Dragan Cvetkovic,

To be or not to be is true. G. Boole No it isn't. L. E. J. Brouwer

!!! Sender/From address is bogus. Use reply-to one !!!
Phil Endecott

2005-06-14, 5:56 pm

Martin Vorbrodt wrote:
> Can I call shmat to attach to a shared memory segment after I called
> shmctl(_id, IPC_RMID, 0) on it (marked it for destruction). I can't seam to
> be able to do it under linux (fedora core 3). it that a standard behaviour?
> can't find anything about it in the "man smhctl"


Hi Martin,

I asked the same question here a few weeks ago:

http://groups-beta.google.com/group...26cd5a022e59d43

The answer is that no, you can't attach to a segment after it is marked
for deletion. Although deletion is postponed until the last process
detaches, new attachments are immediately impossible.


--Phil.
Phil Endecott

2005-06-14, 5:56 pm

Martin Vorbrodt wrote:
> Can I call shmat to attach to a shared memory segment after I called
> shmctl(_id, IPC_RMID, 0) on it (marked it for destruction). I can't seam to
> be able to do it under linux (fedora core 3). it that a standard behaviour?
> can't find anything about it in the "man smhctl"


Having reviewed my previous posts, let me revise my answer:

After calling shmctl(IPC_RMID) you can no longer call shmget(). But you
can still call shmat().

I think.

--Phil.
Michael Kerrisk

2005-06-15, 2:49 am

On Tue, 14 Jun 2005 15:54:46 GMT, Phil Endecott
<phil_nn05@chezphil.org> wrote:

>Martin Vorbrodt wrote:
>
>Having reviewed my previous posts, let me revise my answer:
>
>After calling shmctl(IPC_RMID) you can no longer call shmget(). But you
>can still call shmat().


Yes, but only on Linux. SUSv3 does not require this, and most other
systems don't permit it. Don't do it if you want portability.

Cheers,

Michael
Martin Vorbrodt

2005-06-15, 6:10 pm

thanx!

yet another thing,
signature for shmat under linux is: shmat(int, const void*, int), on mac os
x it's: shmat(int, void*, int);

anyone knows why the difference in constness?


"Michael Kerrisk" <michael.kerrisk.at.gmx.net@nospam.com> wrote in message
news:bjkva1hr71hams3n77o2r0g6doff9dgrks@
4ax.com...
> On Tue, 14 Jun 2005 15:54:46 GMT, Phil Endecott
> <phil_nn05@chezphil.org> wrote:
>
seam to[vbcol=seagreen]
behaviour?[vbcol=seagreen]
>
> Yes, but only on Linux. SUSv3 does not require this, and most other
> systems don't permit it. Don't do it if you want portability.
>
> Cheers,
>
> Michael



Dragan Cvetkovic

2005-06-15, 6:10 pm

"Martin Vorbrodt" <mvorbrodt@poczta.onet.pl> writes:

> thanx!
>
> yet another thing,
> signature for shmat under linux is: shmat(int, const void*, int), on mac os
> x it's: shmat(int, void*, int);
>
> anyone knows why the difference in constness?
>


Well, POSIX specifies

void *shmat(int shmid, const void *shmaddr, int shmflg);

Bye, Dragan

--
Dragan Cvetkovic,

To be or not to be is true. G. Boole No it isn't. L. E. J. Brouwer

!!! Sender/From address is bogus. Use reply-to one !!!
Michael Kerrisk

2005-06-17, 7:58 am

On Wed, 15 Jun 2005 12:50:37 -0400, "Martin Vorbrodt"
<mvorbrodt@poczta.onet.pl> wrote:

>thanx!
>
>yet another thing,
>signature for shmat under linux is: shmat(int, const void*, int), on mac os
>x it's: shmat(int, void*, int);
>
>anyone knows why the difference in constness?


Where do you find that declaration in Linux? It isn't so in (current)
Linux manual pages of glibc headers (and nor is in so even in old man
pages and headers)...

Cheers,

Michael
Martin Vorbrodt

2005-06-20, 6:05 pm

man shmat



"Michael Kerrisk" <michael.kerrisk.at.gmx.net@nospam.com> wrote in message
news:e3a5b1tv9ohmrpkf07c7o7uf1qs5i0leus@
4ax.com...
> On Wed, 15 Jun 2005 12:50:37 -0400, "Martin Vorbrodt"
> <mvorbrodt@poczta.onet.pl> wrote:
>
os[vbcol=seagreen]
>
> Where do you find that declaration in Linux? It isn't so in (current)
> Linux manual pages of glibc headers (and nor is in so even in old man
> pages and headers)...
>
> Cheers,
>
> Michael



Martin Vorbrodt

2005-06-20, 6:05 pm

vi /usr/include/sys/shm.h



"Michael Kerrisk" <michael.kerrisk.at.gmx.net@nospam.com> wrote in message
news:e3a5b1tv9ohmrpkf07c7o7uf1qs5i0leus@
4ax.com...
> On Wed, 15 Jun 2005 12:50:37 -0400, "Martin Vorbrodt"
> <mvorbrodt@poczta.onet.pl> wrote:
>
os[vbcol=seagreen]
>
> Where do you find that declaration in Linux? It isn't so in (current)
> Linux manual pages of glibc headers (and nor is in so even in old man
> pages and headers)...
>
> Cheers,
>
> Michael



Sponsored Links






Free braindumps | Software forum | Database administration forum

Copyright 2003 - 2008 webservertalk.com