SysV IPC
authorJarkko Hietaniemi <jhi@iki.fi>
Thu, 25 May 2006 18:49:33 +0000 (21:49 +0300)
committerSteve Peters <steve@fisharerojo.org>
Fri, 26 May 2006 15:03:12 +0000 (15:03 +0000)
Message-ID: <4475D20D.9010600@gmail.com>

p4raw-id: //depot/perl@28313

ext/IPC/SysV/Msg.pm
ext/IPC/SysV/Semaphore.pm
ext/IPC/SysV/SysV.pm
pod/perlipc.pod

index fadd38f..1edff3b 100644 (file)
@@ -112,10 +112,10 @@ IPC::Msg - SysV Msg IPC object class
 
 =head1 SYNOPSIS
 
-    use IPC::SysV qw(IPC_PRIVATE S_IRWXU);
+    use IPC::SysV qw(IPC_PRIVATE S_IRUSR S_IWUSR);
     use IPC::Msg;
 
-    $msg = new IPC::Msg(IPC_PRIVATE, S_IRWXU);
+    $msg = new IPC::Msg(IPC_PRIVATE, S_IRUSR | S_IWUSR);
 
     $msg->snd(pack("l! a*",$msgtype,$msg));
 
@@ -152,7 +152,9 @@ associated with it, and C<I<FLAGS> & IPC_CREAT> is true.
 =back
 
 On creation of a new message queue C<FLAGS> is used to set the
-permissions.
+permissions.  Be careful not to set any flags that the Sys V
+IPC implementation does not allow: in some systems setting
+execute bits makes the operations fail.
 
 =item id
 
index 94ccf91..8717a93 100644 (file)
@@ -154,10 +154,10 @@ IPC::Semaphore - SysV Semaphore IPC object class
 
 =head1 SYNOPSIS
 
-    use IPC::SysV qw(IPC_PRIVATE S_IRWXU IPC_CREAT);
+    use IPC::SysV qw(IPC_PRIVATE S_IRUSR S_IWUSR IPC_CREAT);
     use IPC::Semaphore;
 
-    $sem = new IPC::Semaphore(IPC_PRIVATE, 10, S_IRWXU | IPC_CREAT);
+    $sem = new IPC::Semaphore(IPC_PRIVATE, 10, S_IRUSR | S_IWUSR | IPC_CREAT);
 
     $sem->setall( (0) x 10);
 
@@ -198,7 +198,9 @@ associated with it, and C<I<FLAGS> & IPC_CREAT> is true.
 =back
 
 On creation of a new semaphore set C<FLAGS> is used to set the
-permissions.
+permissions.  Be careful not to set any flags that the Sys V
+IPC implementation does not allow: in some systems setting
+execute bits makes the operations fail.
 
 =item getall
 
index 7645ced..937acd6 100644 (file)
@@ -74,7 +74,20 @@ IPC::SysV - SysV IPC constants
 
 C<IPC::SysV> defines and conditionally exports all the constants
 defined in your system include files which are needed by the SysV
-IPC calls.
+IPC calls.  Common ones include
+
+   IPC_CREATE IPC_EXCL IPC_NOWAIT IPC_PRIVATE IPC_RMID IPC_SET IPC_STAT
+   GETVAL SETVAL GETPID GETNCNT GETZCNT GETALL SETALL
+   SEM_A SEM_R SEM_UNDO
+   SHM_RDONLY SHM_RND SHMLBA
+
+and auxiliary ones
+
+   S_IRUSR S_IWUSR S_IRWXU
+   S_IRGRP S_IWGRP S_IRWXG
+   S_IROTH S_IWOTH S_IRWXO
+
+but your system might have more.
 
 =over 4
 
index a0357e0..3de879f 100644 (file)
@@ -309,7 +309,7 @@ There were two things you could do, knowing this: be paranoid or be
 pragmatic.  The paranoid approach was to do as little as possible in your
 signal handler.  Set an existing integer variable that already has a
 value, and return.  This doesn't help you if you're in a slow system call,
-which will just restart.  That means you have to C<die> to longjump(3) out
+which will just restart.  That means you have to C<die> to longjmp(3) out
 of the handler.  Even this is a little cavalier for the true paranoiac,
 who avoids C<die> in a handler because the system I<is> out to get you.
 The pragmatic approach was to say "I know the risks, but prefer the
@@ -1537,10 +1537,10 @@ you weren't wanting it to.
 
 Here's a small example showing shared memory usage.
 
-    use IPC::SysV qw(IPC_PRIVATE IPC_RMID S_IRWXU);
+    use IPC::SysV qw(IPC_PRIVATE IPC_RMID S_IRUSR S_IWUSR);
 
     $size = 2000;
-    $id = shmget(IPC_PRIVATE, $size, S_IRWXU) || die "$!";
+    $id = shmget(IPC_PRIVATE, $size, S_IRUSR|S_IWUSR) || die "$!";
     print "shm key $id\n";
 
     $message = "Message #1";
@@ -1615,9 +1615,9 @@ which is included with Perl starting from Perl 5.005.
 
 A small example demonstrating SysV message queues:
 
-    use IPC::SysV qw(IPC_PRIVATE IPC_RMID IPC_CREAT S_IRWXU);
+    use IPC::SysV qw(IPC_PRIVATE IPC_RMID IPC_CREAT S_IRUSR S_IWUSR);
 
-    my $id = msgget(IPC_PRIVATE, IPC_CREAT | S_IRWXU);
+    my $id = msgget(IPC_PRIVATE, IPC_CREAT | S_IRUSR | S_IWUSR);
 
     my $sent = "message";
     my $type_sent = 1234;