rmstar.c

来自「<B>Digital的Unix操作系统VAX 4.2源码</B>」· C语言 代码 · 共 63 行

C
63
字号
#ifndef lintstatic char	*sccsid = "@(#)rmstar.c	4.1	(ULTRIX)	11/23/87";#endif lint/* * rmstar.c * * Name:	rmstar * Purpose:	Remove shared memory segment. * Environment:	Ultrix-32, with shared memory. * Compile:	see Makefile * Date:	April 19 1985 * Author:	Alan Delorey * Remarks:    These are the voyages of the independent star ships.Whose lifetime mission: To explore strange new galaxies,		        To seek out and destroy other star ships,		        To boldly go where no other star ship dares!*//* * Modification history * */#include "star.h"#include <sys/types.h>#include <sys/ipc.h>#include <sys/shm.h>int shmid;			/* shared memorey id */struct univ *uptr;extern errno;char *shmat();			/* shared mem attach routine */main(argc, argv)    int argc;    char *argv[];{if ((shmid = shmget(ftok("/usr/games/starship", 'a'), sizeof(struct univ), 0666)) < 0)    {    printf("%s: shmget failed, errno = %d\n", argv[0], errno);    perror("rmstar");    exit();    }if ((uptr = (struct univ *) shmat(shmid, 0, 0)) < 0)    {    printf("%s: shmat failed, errno = %d\n", argv[0], errno);    perror("rmstar");    exit();    }if (shmctl(shmid, IPC_RMID) < 0)    {    printf("shmctl call to remove shared seg failed\n");    perror("rmstar");    exit();    }printf("Shared memory segment removed.\n");}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?