home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #19 / NN_1992_19.iso / spool / comp / unix / question / 10625 < prev    next >
Encoding:
Internet Message Format  |  1992-09-01  |  1.8 KB

  1. Path: sparky!uunet!mcsun!uknet!stl!robobar!ibmpcug!impmh!dsg
  2. From: dsg@impmh.uucp (Dave Gordon)
  3. Newsgroups: comp.unix.questions
  4. Subject: Re: Shared memory baby question on ultrix 4.2
  5. Summary: shared memory permissions
  6. Keywords: shared memory permissions
  7. Message-ID: <1992Sep1.155624.2149@impmh.uucp>
  8. Date: 1 Sep 92 15:56:24 GMT
  9. References: <1992Aug17.152207.3268@otago.ac.nz>
  10. Organization: Integrated Micro Products Ltd
  11. Lines: 46
  12.  
  13. In comp.unix.questions deano@piglet.otago.ac.nz writes:
  14.  
  15. > Help Help Help
  16. >
  17. > I don't understand shared memory.  Sorry, but all I can find in the
  18. > documentation for our DECstations is the man pages which tell me what to use
  19. > and what to pass but not HOW to use ?!?!?!?!?!?
  20. >
  21. > at the moment I do this :
  22. >
  23. > key = ftok("/tmp", 'a');
  24. > shmid = shmget(key, 64, IPC_CREAT | IPC_EXCL);
  25. > s = shmat(shmid, 0, SHM_R | SHM_W);
  26. >
  27. > *s = 1; /* BARF BARF BARF, kernel acces since s == -1 */
  28. >
  29. > help help help
  30.  
  31.  
  32.  
  33. deano's problem is in the parameters to the shmget(2) call ...
  34. the third parameter should include the permissions (modes) for
  35. the new segment; the manual page on our system reads:
  36.  
  37.       The low-order 9 bits of shm_perm.mode are set equal to the
  38.             low-order 9 bits of shmflg.
  39.  
  40. The shared-memory segment is created with no permissions for
  41. anybody, so the shmat(2) call fails (returns -1).
  42.  
  43. The permissions are just like those used for files, except that
  44. there is no 'execute' mode.  So the third parameter could be
  45.         (IPC_CREAT|IPC_EXCL|0666)
  46. which gives read/write permission to everybody, or some other modes,
  47. according to what is wanted.
  48.  
  49. ipcs(1) will display the status of shared memory segments including
  50. permissions.
  51.  
  52.  
  53. PS:
  54. deano: I tried to mail this to deano@piglet.otago.ac.nz, but it
  55. bounced at uknet.ac.uk; are you sure about your mail address??
  56. -- 
  57.             Dave
  58.             ====
  59.