ALT Linux Sisyphus discussions
 help / color / mirror / Atom feed
From: Grigory Batalov <bga-no-spam@kovgok.ru>
To: ALT Linux Sisyphus discussion list <sisyphus@altlinux.ru>
Subject: Re: [sisyphus] Shared memory - HELP PLEASE!
Date: Thu, 25 Mar 2004 09:42:45 +0300
Message-ID: <20040325094245.5814ff9b.bga-no-spam@kovgok.ru> (raw)
In-Reply-To: <200403242336.15940.iadzhubey@rics.bwh.harvard.edu>

[-- Attachment #1: Type: text/plain, Size: 765 bytes --]

On Wed, 24 Mar 2004 23:36:15 -0500
Ivan Adzhubey <iadzhubey@rics.bwh.harvard.edu> wrote:

> Видимо придется все же самому разбираться. Может кто-нибудь поделится 
> исходниками чего-то работающего с shm, что у него самого - работает? Или хотя 
> бы фрагментом. Буду признателен.

  У меня сохранился небольшой тест. Кажется, без ошибок =).
  Во время sleep(5) запустите ipcs - увидите выделенный 1К.

$ gcc -g -Wall -O2 -o shmtest shmtest.c
$ ./shmtest &
$ ipcs

------ Shared Memory Segments --------
key        shmid      owner      perms      bytes      nattch     status      
0x00000000 1245187    bga       700        1048576    1                       

-- 
Григорий Баталов,
начальник бюро
системного администрирования
ОАО "Ковдорский ГОК"
+7-(81535)-76036

[-- Attachment #2: shmtest.c --]
[-- Type: text/plain, Size: 749 bytes --]

#include <sys/types.h>
#include <sys/ipc.h>
#include <sys/shm.h>
#include <errno.h>
#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>

int main(void)
{
	int shmid = -1;
	char *result;
	
	shmid = shmget(IPC_PRIVATE, 1024*1024, IPC_CREAT|0700);

	if(shmid == -1) {
		perror("shmget");
		exit(EXIT_FAILURE);
	}

	result = (char *)shmat(shmid, NULL, 0);

	if(result == (char *)-1) {
		int save_errno = errno;
		if(shmctl(shmid, IPC_RMID, NULL) == -1) {
			perror("shmctl");
		}

		errno = save_errno;
		perror("shmat");
		exit(EXIT_FAILURE);
	}

	sleep(5);
	
	if(shmctl(shmid, IPC_RMID, NULL) == -1) {
		perror("shmctl");
		exit(EXIT_FAILURE);
	}

	if(shmdt(result) == -1) {
		perror("shmdt");
		exit(EXIT_FAILURE);
	}

	exit(EXIT_SUCCESS);
}


  parent reply	other threads:[~2004-03-25  6:42 UTC|newest]

Thread overview: 33+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-03-24 22:17   ` Ivan Adzhubey
2004-03-25  4:14     ` Eugene Ostapets
2004-03-25  4:36       ` Ivan Adzhubey
2004-03-25  4:43         ` Denis S. Filimonov
2004-03-25  4:50           ` Ivan Adzhubey
2004-03-25  5:04         ` Eugene Ostapets
2004-03-25  6:53           ` Ivan Adzhubey
2004-03-25  7:44           ` Serj
2004-03-25  8:28             ` Ivan Adzhubey
2004-03-25  5:09         ` Mike Lykov
2004-03-25  5:23           ` Ivan Adzhubey
2004-03-25  5:28             ` Mike Lykov
2004-03-25  5:30               ` Ivan Adzhubey
2004-03-25  6:42         ` Grigory Batalov [this message]
2004-03-25  7:05           ` Ivan Adzhubey
2004-03-25  7:17             ` Ivan Adzhubey
2004-03-25  7:29               ` Ivan Adzhubey
2004-03-25  7:59                 ` Ivan Adzhubey
2004-03-25  7:44               ` Grigory Batalov
2004-03-25  8:09                 ` Ivan Adzhubey
2004-03-25  8:24                 ` Ivan Adzhubey
2004-03-25 11:54                   ` Sergey Vlasov
2004-03-25  4:22     ` Denis S. Filimonov
2004-03-25 12:22     ` Sergey Vlasov
2004-03-25 12:58       ` [JT] снова проблемы от security fixes? (WAS: Re: [sisyphus] Shared memory - HELP PLEASE!) Andrei Bulava
2004-03-25 13:12         ` Sergey Vlasov
2004-04-06  8:57     ` [sisyphus] Shared memory - HELP PLEASE! Sergey Vlasov
2004-04-06  9:08       ` Ivan Adzhubey
2004-04-06  9:24         ` Dmitry V. Levin
2004-04-06  9:50         ` Sergey Vlasov
2004-04-06 21:06           ` Ivan Adzhubey
2004-04-07  6:25             ` Sergey Vlasov
2004-04-07 16:12               ` Ivan Adzhubey

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=20040325094245.5814ff9b.bga-no-spam@kovgok.ru \
    --to=bga-no-spam@kovgok.ru \
    --cc=sisyphus@altlinux.ru \
    /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

ALT Linux Sisyphus discussions

This inbox may be cloned and mirrored by anyone:

	git clone --mirror http://lore.altlinux.org/sisyphus/0 sisyphus/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 sisyphus sisyphus/ http://lore.altlinux.org/sisyphus \
		sisyphus@altlinux.ru sisyphus@altlinux.org sisyphus@lists.altlinux.org sisyphus@lists.altlinux.ru sisyphus@lists.altlinux.com sisyphus@linuxteam.iplabs.ru sisyphus@list.linux-os.ru
	public-inbox-index sisyphus

Example config snippet for mirrors.
Newsgroup available over NNTP:
	nntp://lore.altlinux.org/org.altlinux.lists.sisyphus


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git