SYSV IPC via the shell?

SYSV IPC via the shell?

Post by J. S. Jense » Wed, 16 Jun 1999 04:00:00



Are there any C wrappers for the IPC message/semaphore/shmem that can be
effectively used within a shell?

After trying to make some quick IPC wrappers that I can use within a
shell enviornment (ipc messages coming out on stdout, etc, accessed via
command line) I've realized it is a non-trivial task.

Anybody ever used SYSV IPC w/ a shell like this?  (I'd much rather
script my problem solution than write it all in a monolithic program).

--
J. S. Jensen

http://www.Paramin.COM

 
 
 

SYSV IPC via the shell?

Post by Tom Christianse » Wed, 16 Jun 1999 04:00:00


     [courtesy cc of this posting mailed to cited author]

In comp.unix.shell,

:Anybody ever used SYSV IPC w/ a shell like this?  (I'd much rather
:script my problem solution than write it all in a monolithic program).

Well, Perl can certainly handle it.  There are some issues
that don't map well to the separate-execution model.

--tom
--
"Training is everything.  The peach was once a bitter almond.  Cauliflower is
 nothing but cabbage with a college education."
                                - Mark Twain

 
 
 

SYSV IPC via the shell?

Post by J. S. Jense » Wed, 16 Jun 1999 04:00:00




> :Anybody ever used SYSV IPC w/ a shell like this?  (I'd much rather
> :script my problem solution than write it all in a monolithic program).
> Well, Perl can certainly handle it.  There are some issues that don't map well
> to the separate-execution model.

I'm having difficulties with the header translation (h2ph) for reasons a little
unknown to me.  My Linux SYSV IPC header files seem not to have appropriate flags
defined (MSG_R & MSG_W) for instance, nor are the error codes defined, though I
consistently get -1 on my errors, not what the man page lists for error codes.

Wondering if the perl h2ph as well won't convert the non-existent flags...(of
course it won't) but I'm beginning to learn the intracies of a seamingly
non-cared-about SYSV IPC Linux issue.

Is there any benefit to using the CPAN IPC::SysV modules vs. the msgsnd/rcv core
perl subs?

--
J. S. Jensen

http://www.Paramin.COM

 
 
 

SYSV IPC via the shell?

Post by Tom Christianse » Wed, 16 Jun 1999 04:00:00


     [courtesy cc of this posting mailed to cited author]

     [notice how nice it is to know this was mailed, unlike
      what just happened to me :-( ]


:Is there any benefit to using the CPAN IPC::SysV modules

IPC::SysV should be standard now, not just CPAN.  h2ph header translation
has gotten better, but you should happily not have to use it.

--tom
--
    X-Windows: Some voids are better left unfilled.
        --Jamie Zawinski

 
 
 

SYSV IPC via the shell?

Post by brian hile » Thu, 17 Jun 1999 04:00:00



Quote:> Are there any C wrappers for the IPC message/semaphore/shmem that can be
> effectively used within a shell?
> After trying to make some quick IPC wrappers that I can use within a
> shell enviornment (ipc messages coming out on stdout, etc, accessed via
> command line) I've realized it is a non-trivial task.
> Anybody ever used SYSV IPC w/ a shell like this?  (I'd much rather
> script my problem solution than write it all in a monolithic program).

First of all, it is to be noted and emphasized that the _built-in_
IPC features of shell, especially ksh88 and ksh93, are very much
more powerful than are generally realised by those who have not
carefully read the man pages.

Signals are, of course, fully implemented and function identically
to their equivalent system calls.

File locking and asynchronous job monitoring can be completely (if
not especially efficiently) implemented using native shell code
involving blocking on link(1) to a (non-existent) directory or
manipulating and parsing the output of the "jobs" builtin. I have
such functions...  at home, unfortunately (I'm writing a function
library for a shell IDE I have been authoring for these past couple
of years.)

Manipulating sockets is especially easy in ksh93 and late versions
of ksh88 (not tested.)

print foobar >/dev/tcp/127.0.0.1/7   # print "foobar" to the TCP ECHO port
read </dev/tcp/127.0.0.1/7           # of the local host.

read </dev/tcp/127.0.0.1/13          # read from the time-of-day port
print -r -- "$REPLY"

Using the above technique, I have seen a rudimentary HTTP server
written in 20 lines of ksh93 code!

The special "file" /dev/{udp|tcp}/<ip-number>/<port-number> is
recognized specially by ksh to know to perform the internals of
open/listen-for a socket, etc. These files do _not_ have to exist
on the OS -- except for the case when the vendors have inadvertently
created a character special file by this name -- and then ksh will
guess you mean the real files and effectively shroud this feature,
as for example on my IRIX 5.x :(

In addition, there exists source code wrappers for the common IPC features:

shell level access to flock(2)
ftp.uu.net/usenet/comp.sources.misc/volume5/flock

Shared Memory:
http://netlib.bell-labs.com/netlib/research/shm/svid.c.gz
http://netlib.bell-labs.com/netlib/research/shm/shmid.c.gz
http://netlib.bell-labs.com/netlib/research/shm/isshm.c.gz

tcp_wrappers - TCP/IP daemon wrappers, v7.0
ftp.uu.net/usenet/comp.sources.misc/volume47/tcp_wrappers/part0[1-7]
ftp.uu.net/usenet/comp.sources.misc/volume47/tcp_wrappers/patch01

ftp://ftp.dfn.de/pub/security/tcpwrapper/

www.ftpsearch.com is a fine resource for locating such utilities and shells
that you have in mind.

Unfortunately, I have never come across any wrapper over System V
Messages -- you _are_ aware that messages are an obsolete IPC
features? By all means if you should need to write your own would
you make the code freely available to the benefit of all?

-Brian

 
 
 

SYSV IPC via the shell?

Post by J. S. Jense » Thu, 17 Jun 1999 04:00:00



> First of all, it is to be noted and emphasized that the _built-in_ IPC features
> of shell, especially ksh88 and ksh93, are very much more powerful than are
> generally realised by those who have not carefully read the man pages.

Oh, please don't get me wrong, I /do/ heavily use signals, traps, and suid kills.

What I was of especially in need was message passing (queueing)...

Quote:> Unfortunately, I have never come across any wrapper over System V Messages --
> you _are_ aware that messages are an obsolete IPC features?

No...actually, I was /not/ aware that they are obsolete.  Why is this?  I've been
in the big iron too long I guess...

Quote:> By all means if you should need to write your own would you make the code
> freely available to the benefit of all?

As any good programer would! ;-)  I was hoping to implement a queueing system
(much like IBM's MQSeries) that I could associate `filters' to the incoming data
on each queue where the data could be manipulated by shell/awk/sed (combo
pipeline) whatever, then either re-queued elsewhere (other systems, or other
internal queues) or killed.  I was using modified BSD LPD code to implement this
(as LPD actually /can/ make this work) but the filters associated with LPD are
called with only ONE passing parameter, and work-arounds are needed to have
MESSAGE PASSING.

Thus my question...

BTW:  My message passing IPC wrappers are now working on AIX 4, but not on
Linux...

--
J. S. Jensen

http://www.Paramin.COM

 
 
 

1. Posix.1b IPC and SysV IPC

 I'm studying a book on UNIX programming and in the SysV IPC chapter
the book states that these interfaces will soon be obsoleted by
improved Posix interfaces to solve the same IPC problems. I tried
finding info on this and all I came up with was that Posix.1b now
incorporates these calls and that shared memory is implemented as
mmap() in Posix.1b. Are these the only changes? What about semaphores
and message queues? Do these "new" Posix calls use file descriptors or
are they still non-UNIX-oriented as the SysV calls?

        Thanks,
        Yoav

2. Help: make and archives

3. Berkeley IPC & SysV IPC

4. Turning off RFC931 in tcpd

5. I want a teeny SysV Bourne Shell-compliant shell

6. mru, mtu and other pppd tweaks for X2??

7. How to discover current SYSV IPC status under Solaris 5.3

8. Plug N Play in Linux

9. SYSV IPC:function not implemented

10. SYSV/Posix IPC with fds.

11. SysV IPC question

12. IPC class (SYSV)

13. SysV IPC, kernel 2.4.3