HDTenEightyP/NetNews huggingface dataset:
From: heistand@iastate.edu (Steve W Heistand)
Subject: IPC help please
Summary: I need IPC help
Keywords: sockets communication
Organization: Iowa State University, Ames IA
Date: Thu, 16 Apr 1992 23:54:27 GMT

I have one simple question: how can two arbitrary processes
on two different machines talk to each other.  Each is
wants to talk to the other but have no idea where the other
one is.  They are however owned by the same account.
thanks loads.

steve
From: adrian@milton.u.washington.edu (Adrian Mariano)
Newsgroups: comp.unix.programmer
Subject: Signals to child processes
Date: 14 Apr 92 23:15:13 GMT
Reply-To: adrian@u.washington.edu
Organization: University of Washington, Seattle

I have a program which is running a telnet as a child process (a
pipe).  If I hit ^Z (sending SIGTSTP to the parent), the child telnet
receives some signal which causes it to lose its connection.

If I hit ^Z when using telnet directly, it is tramsmitted to the
remote host which then drops the connection, but if I use ^] to get to
the telnet prompt first, I can suspend the telnet without problems.  
How can I duplicate this behavior when the telnet is running as the
child?
Newsgroups: comp.unix.programmer
From: Tom Christiansen <tchrist@convex.COM>
Subject: Re: Scripting in general
Originator: tchrist@pixel.convex.com
Reply-To: tchrist@convex.COM (Tom Christiansen)
Organization: CONVEX Realtime Development, Colorado Springs, CO
Date: Tue, 14 Apr 1992 17:40:48 GMT
X-Disclaimer: This message was written by a user at CONVEX Computer
              Corp. The opinions expressed are those of the user and
              not necessarily those of CONVEX.

From the keyboard of bengtl@maths.lth.se (Bengt Larsson):
:My wish would be for a new, C-like scripting language, with dynamic
:typing, and string handling (and regexps) builtin. There was a man page
:posted for such a language about a year ago. I can repost it, if there's
:interest.

I'd say perl meets your criteria listed here.

:With such a language you could possibly implement quite a lot of things
:as scripts, in a safe way. Perl is a little too much... Perl IMO.

What precisely do you mean?  Larry's thinking about perl5, and constructive
input might have a chance of altering whatever is bothering you here.

--tom
Newsgroups: comp.unix.programmer
From: harry@wsl.ie (Harry Moreau)
Newsgroups: comp.unix.programmer
Subject: Re: simple input/output redirection
Date: 6 Apr 92 14:17:22 GMT
Distribution: comp
Organization: Workhorse Systems Limited, Dublin, Ireland

dylan@ibmpcug.co.uk (Matthew Farwell) writes:
: In article <1992Apr2.111920.6963@wsl.ie> harry@wsl.ie (Harry Moreau) writes:
: >mmoore%peruvian.utah.edu@cs.utah.edu (Michael Moore) writes:
: >:   Hello all, I have a simple question for you:
: >:   I guess what I am asking is is there some function to return
: >: what file descriptors these streams (stdin, stdout, stderr) are pointing
: >: to?
: ># include    <stdio.h>
: >
: >main()
: >{
: >    FILE    *fp;
: >
: >    (void) fclose( stderr );
: >    fp = fopen( "myfile", "w" );
: >    /* stderr is now pointing to myfile!! */
: >    fprintf( stderr, "I should go into stderr\n" );
: >    return 0;
: >}
: 
: This might (or might not) work, depending on whether the moon is blue,
: etc.  You should use freopen instead...

Mr. Farwell has totally misinterpreted and misrepresented the intent 
of my posting on this subject.  

The example code that I used was in no way intended as a 
recommended way of closing stderr and opening it on some other file.
I was, rather, trying to highlight the possibility of confusion resulting
from closing the standard streams, which is what the original poster
seemed to be asking about.

--harry

Henry M. Moreau,  Tecnical Director, Workhorse Systems Ltd.

email: harry@wsl.ie
From: barmar@think.com (Barry Margolin)
Newsgroups: comp.unix.programmer
Subject: Re: Designing Client-Server Communications
Date: 12 Apr 1992 07:36:20 GMT
Organization: Thinking Machines Corporation, Cambridge MA, USA
NNTP-Posting-Host: gandalf.think.com

In article <1992Apr11.214349.1@vaxs.sscl.uwo.ca> operator@vaxs.sscl.uwo.ca writes:
>To minimize net traffic and write local disk logs (instead of NFS)
>one server machine sends a "heart-beat" every n seconds to clients

>UDP with Broadcast.. parent broadcasts UDP packet

This will normally only work if all the machines are on the same subnet,
since routers don't usually forward broadcasts.

It also causes a small amount of overhead on non-client machines on the
local subnet.

>TCP with mult-port (1 port per client)

Do you need a permanent TCP connection for this?  UDP would probably be
better for this; if you were considering broadcast UDP, then directed UDP
should be just as good.  It will cause more network traffic than the
broadcast scheme, but less than TCP.

>TCP with 1 port (is it possible?)

Not possible.  TCP is a one-to-one protocol.
-- 
Barry Margolin
System Manager, Thinking Machines Corp.

barmar@think.com          {uunet,harvard}!think!barmar
Newsgroups: comp.unix.programmer
From: operator@vaxs.sscl.uwo.ca
Subject: Designing Client-Server Communications
Organization: University of Western Ontario
Date: Sun, 12 Apr 1992 02:43:49 GMT

Hi.. 
I am working on a socket-level application, and I want to check out
the advantages and disadvantages of designing the program in a 
certain way.

The appliction I am working on is a remote CPU monitoring tool.
To minimize net traffic and write local disk logs (instead of NFS)
one server machine sends a "heart-beat" every n seconds to clients
on other machines.  The clients then snapshot the local CPU and log it.

I have a couple of questions...  

I am considering:

UDP with Broadcast.. parent broadcasts UDP packet
TCP with mult-port (1 port per client)
TCP with 1 port (is it possible?)
 
What is the preferred way to handle the client-server communiction?

For grabbing CPU stats, I am considering:

pipe to ps
hacking up top source code

Is there a better way?

Thanks in advance,

Bill McLean
University Of Western Ontario
London, Ontario CANADA

mclean@gaul.csd.uwo.ca
From: sium@syma.sussex.ac.uk (Siu Mak)
Newsgroups: comp.unix.programmer
Subject: Re: Effective user ID's
Date: 13 Apr 92 19:24:43 GMT
Organization: University of Sussex at Brighton

In article <1992Apr13.075024.26582@descartes.waterloo.edu>, dcborean@descartes.waterloo.edu (David Borean) writes:
>
> I have a small question.. I'm fairly new to UNIX and am just getting interested
> in actually programming unix stuff.. I've experimented with shells and they're
> interesting but C is where it's at.. However, I have a problem.. I've come
> accross commands for setting effective user ID's and effective user Group ID's
> and was wondering exactly how you do that.  How can you set an Effective
> User ID? and then set UID to EUID?
>
> Any help on this would be appreciated.. also, the applications of such a
> procedure would also be appreciated.. obviously setting your effective
> ID to root isn't going to give ou Root's access.. So any applications to these
> commands would be appreciated..
>
>
> Thanks..

Have you tried to look in the man pages ?
I think there are too many methods could achieve the fact, but the appropriate
one can only be chosed if the purpose is cleared.
Newsgroups: comp.unix.programmer
From: marcus@cbr.dwr.csiro.au (Marcus Schnell)
Subject: recursively moving to directories
Organization: CSIRO Division of Water Resources
Date: Tue, 7 Apr 1992 00:41:37 GMT

Hi all,

Beginners shell programming question:

I want to recursively move down directories and changing the owner of
the file. This script would be run by root. ie. examine each directory
entry, if a file change owner to X, it directory cd to that directory.

Thanks ,

Marcus

****************************************************************************
*    Marcus Schnell                      marcus@helios.cbr.dwr.csiro.au    *
*    CSIRO Division of Water Resources   Phone   : (+61 6) 246 5707        *
*    GPO Box 1666                        FAX     : (+61 6) 246 5800        *
*    Canberra                            Int FAX : (+61 6) 246 5800        *
*    ACT  2601    **********************************************************
*    Australia    *          insert ".disclaim" here...                    *
****************************************************************************

Newsgroups: comp.unix.programmer
From: amichail@descartes.waterloo.edu (Amir Michail)
Subject: indirect goto
Organization: University of Waterloo
Date: Tue, 7 Apr 1992 01:57:58 GMT

I need to make a indirect goto in C depending upon a value of a 
variable.  The only way I can think of doing it as follows:

l1:
<< code >>

l2:
<< code >.

l3:
<< code >>

now, suppose I want to jump to l1, l2 or l3 depending on whether
the variable d = 0 or 1 or 2 respectively.  I could try

switch(d){
case 1 : goto l1;
case 2 : goto l2;
case 3 : goto l3;
}

The only problem is, d could have many values in my program,
perhaps 10000 or so.

Is there any other way I could do this?


Also, I have another question about trapping segmentation violations.

Suppose, I have an array A of size 10.  Then
the statement a = A[2000] will cause a segmentation violation.  The
point is I wish to trap it and perform some action, then return
to the code and continue processing.  However, I keep getting
repeated segmentation violations as 'a = A[2000]' is executed over and
over again.  I tried putting an index i, i.e. a = A[i], then changing
i back to 0 in my error handler routine.  However, this does not
fix the problem.  Any clue on how to do this?

Amir
Newsgroups: comp.unix.programmer,comp.unix.internals,comp.unix.wizards
From: terry@ithaca.npd.Novell.COM (Terry Lambert)
Subject: Re: What is the system call for microsecond sleep?
Organization: Novell NPD -- Sandy, UT
Date: Mon, 13 Apr 1992 22:31:15 GMT

In article <1992Apr10.204412.20045@lambda.msfc.nasa.gov>, mahmood@lambda.msfc.nasa.gov (Rafique Mahmood) writes:
|> I am developing some portable code in which I need to use microsecond
|> sleep. So, I used usleep(microsecond) system call. The problem is Decstation
|> does not support this call. They have 'napms(milisec)'. How can I get microsec.
|> sleep in my portable code? Is usleep() is POSIX call?


	Write it for a system with a system clock resoloution greater than or equal to 1 uSec.  The
DECStation is 10 uSec.  The closest you will ever get is +/- 10 uSec.  The VAXStation is worse by a
factor of 3.  You could use a timeout on the poll() or select() system calls if you can live with this
resoloution.  If you can't, get a faster box ;-).

	The usleep() call has it's origins in the original Motorolla System V port, which was used by
NCR, Unisys, et al.  You may want to try the more portable setitimer(), but it won't get you any
better resoloution than the hardware has.  It is likely that the DECStation is giving you it's all with the
millisecond timer.


						Terry Lambert
						terry_lambert@gateway.novell.com
						terry@icarus.weber.edu
Xref: sparky comp.unix.programmer:2323 comp.unix.internals:1098 comp.unix.wizards:2161
From: mahmood@lambda.msfc.nasa.gov (Rafique Mahmood)
Newsgroups: comp.unix.programmer,comp.unix.internals,comp.unix.wizards
Subject: What is the system call for microsecond sleep?
Date: 10 Apr 92 20:44:12 GMT
Organization: NASA/MSFC

I am developing some portable code in which I need to use microsecond
sleep. So, I used usleep(microsecond) system call. The problem is Decstation
does not support this call. They have 'napms(milisec)'. How can I get microsec.
sleep in my portable code? Is usleep() is POSIX call?

Thanks,
Rafique Mahmood
Newsgroups: comp.unix.programmer
From: bengtl@maths.lth.se (Bengt Larsson)
Subject: Re: Elegant mass file renamer
Organization: Lund Institute of Technology, Sweden
Date: Mon, 6 Apr 1992 08:22:05 GMT

In article <id.00LO.XCG@ferranti.com> peter@ferranti.com (Peter da Silva) writes:
>In article <1992Mar30.034949.25006@lth.se> bengtl@maths.lth.se (Bengt Larsson) writes:
>> Needs more quoting for `basename $file`.
>
>Yeh, it's cleaner in newer shells.

It's cleaner in rc, at least. I don't know about others.

>> Doesn't handle case of no matching files.
>
>Insert a check. If you're turning this into a script you probably want to.
>My point is that you can do this interactively without a lot of fiddling
>and with few surprises.

Maybe. But this doesn't seem like the kind of loop you might run interactively.
Certainly not often.

>> DCL:
>
>[ deleted ]
>
>And you can just type that right into the $ prompt? 

No, you can't. But you already knew that.

>> $ rename *.foo *.bar
>> !/confirm	With confirmation
>> !/log		With logging
>
>That's a nice special case. 

Yes, it's a nice special case. And what about it? It was your example
precisely because people want to do this. 

>My general version of "rename" would support
>stuff like:
>
>	rename %1.%2.c %1/%2/%2.c

But you haven't written it, probably because it isn't generally needed.

>
>I suspect that the equivalent already exists.

I doubt that anyone saw the need for a special purpose program for that
kind of thing.

>[my program deleted]
>
>> You must be joking.
>
>No, it's a completely undebugged first cut at a program that undoubtedly
>needs some work. There are better versions already out there on the net:
>you just need to pick them up.

Yes. Completely undebugged and needs some work. Why don't you at the
very least try to run scripts before you post them? 

The special version I'm using is "ren", BTW. It's written in C, as
it should be. Perl may also be allright for this.

>[fixed version deleted]
>
>> Observe the four backquotes needed in two places.
>
>Who cares? It's not like the end-user has to see them.

Peter, either you make sure your script works in all cases (you 
didn't even _try_), or the user has to debug it. Or you are ensuring
the hacker's (your) job security. Which is it?

Bengt Larsson.
-- 
Bengt Larsson - bengtl@maths.lth.se
From: Frank@mindlink.bc.ca (Frank I. Reiter)
Newsgroups: comp.unix.programmer
Subject: Re: logging outgoing telnet sessions to catch 'hackers'
Date: 9 Apr 92 23:06:22 GMT
Article-I.D.: mindlink.11347
Organization: MIND LINK! - British Columbia, Canada

> Rob J. Nauta writes:
> 
> I'm not sure about the ethical side of this. This is an invasion of
> privacy, which should be dealt with carefully. Logging and examining
> all telnet sessions is like opening and reading all incoming mail,
> letters and taping all phonecalls.

You may be assuming too much.  Perhaps he only wants to log the fact that a
connection was made, not the entire session.  That was the impression I got.

> But, if you really want to have total control (some people would say
> fascist), you can easily modify the telnet binary to log in a directory
> somewhere, in fact I once adapted the telnet source for this purpose
> but be warned, on an active system it'll generate more logfiles that
> you'll be able to read. Also, if something happens, your logs won't make
> good evidence, i'm sure any judge will be appalled by such system
> management that keeps such detailed logs, also logs you generate
> yourself without police supervision are probably unacceptable as legal
> evidence.

As the original poster pointed out, this will not prevent someone from
recompiling the telnet source to produce their own binary.

Frank.
--
___________________________________________________________________
Frank I. Reiter                Internet: Frank@mindlink.bc.ca
MIND LINK! Communications Corp. Surrey, British Columbia, Canada
Organization: Old Dominion University Computer Services
Date: Thursday, 9 Apr 1992 17:03:37 EDT
From: Pam Skillman <PJS100T@ODUVM.BITNET>
Newsgroups: comp.unix.programmer
Subject:    Which pipe sent SIGPIPE w/o trying to write to it??

Here's the situation:  I've got several pipes to several different processes
and I receive a SIGPIPE.  I don't want to try to write anything to each of
these pipes as some of the processes are running tools and such and I don't
want anything I send interpreted by them.  Is there a way to do this??  A
type of polling without having to write??  Thanks in advance!!

Pam Skillman
Old Dominion University
Computer Services
Technical Support Group
From: les@chinet.chi.il.us (Leslie Mikesell)
Newsgroups: comp.unix.programmer
Subject: Re: Reading from stdin then write to stdout when possible
Date: 15 Apr 92 04:42:09 GMT
Organization: Chinet - Public Access UNIX

In article <1992Apr14.003445.24432@nodecg.ncc.telecomwa.oz.au> adrienne@nodecg.ncc.telecomwa.oz.au (adrienne byrd 4208172) writes:

>I need a program which reads from stdin, and writes what it read
>to stdout.  If stdout is not available, keep reading from stdin.  When
>stdout reappears, start writing to it again.
>
>This would be the software equivalent of a "pressure release value", if you
>like.  We need to read from a named pipe, and write to another named pipe.
>However, if the end which takes its data from the second pipe suddenly
>dies or something, we don't want the reads from the first pipe to stop.

Just open the output side with O_NDELAY or use fcntl() to set it if
the program is handed an open fd instead of the name.  Then the
writes will fail and return immediately if the pipe fills.  Or,
you might set up a signal handler and use alarm() to bail out
of the write if it takes too long if you can afford a few seconds
lag.

>	inout <inpipe >outpipe 2>log
>This does not do what I want (ie the reads don't keep going if I
>kill the cat of outpipe, or if I completely remove outpipe).

Setting O_NDELAY will let the program keep running even when nothing
reads outpipe.  Note, though, that if you remove outpipe your program
will keep working and the connection to a running reader will remain
but you lose the ability to restart another reader connected to
that FIFO.  If you expect the FIFO to be deleted and replaced the
copying program must notice this and re-open the new one.

>I first tried the whole thing using read() on file descriptor 0
>(instead of fread() on stream stdin) and the write() on file 
>descriptor 1 (instead of fwrite()), and just didn't care whether
>my write failed, but that did absolutely nothing (ie, the program
>returned immediately).  This failure to do anything confused me at
>the start, and why the stream io should be different confuses me more.

read() returns what it can from a pipe/fifo as long as at least one
byte has been written.  fread() loops calling read() to fill the
buffer you requested.  All you have to do is pay attention to the
return value from read().

>I suspect I'll need to fork() to do this properly (?), but at this
>stage I would have at least excepted the fread()s to continue as long as
>inpipe still had data placed in it.

Nope, as soon as you stop reading from the other end of the FIFO and
the 5 or 10K buffer fills your copying program will be blocked trying
to write unless you set O_NDELAY or time out with alarm().  You
probably don't want to fork off lots of processes trying to write to
the dead pipe...

Les Mikesell
  les@chinet.chi.il.us
From: dlutz@willamette.edu (David Lutz)
Newsgroups: comp.unix.programmer
Subject: Need help writing Front End
Keywords: Front-End stdin stdout
Date: 5 Apr 92 23:24:43 GMT
Article-I.D.: willamet.1992Apr5.232443.12931
Organization: Willamette University, Salem, OR


Hello--
  I am trying to write a front end for a program and I need some help.

   The idea is something like this.

     FILE *pipe = popen( "program", "rw" );


     while ( test )
     {
        read from pipe only if data is waiting to be read.
        process data.
        read from stdin only if data ready
        process keystokes and send out on the pipe
     }

I assume this needs some kind of non-blocking io calls for the streams,
but I am not sure how to go about doing this.
 
Any help would be appreciated.   Thanks

D.L.
Newsgroups: comp.unix.programmer
From: randy@rss.dl.nec.com (Randy Bullard)
Subject: Re: Need help writing Front End
Keywords: Front-End stdin stdout
Organization: NEC America
Date: Tue, 7 Apr 1992 14:08:58 GMT

In article <1992Apr6.210239.9818@ringer.cs.utsa.edu>, rrybacki@ringer.cs.utsa.edu (Richard M. Rybacki) writes:
|> In article <1992Apr5.232443.12931@willamette.edu> dlutz@willamette.edu (David Lutz) writes:
|> >
|> >Hello--
|> >  I am trying to write a front end for a program and I need some help.
|> >
|> >   The idea is something like this.
|> >
|> >     FILE *pipe = popen( "program", "rw" );
|>                                       ^^ Huh?

Unfortunately you can not do what you are attempting to do with popen().  There is no
read/write mode (i.e. "rw") for a popen call.  You can either open its standard output
for reading or its standard input for writing by using r or w for the type.  If you
need access to both stdin and stdout for the program, then you'll have to create new
file descriptors and fork/exec the program with these new file descriptors in its
environment as stdin and stdout (or somesuch nonsense.  I've done it before but can't
remember the exact procedure.  popen() definitely won't do it though).  See Richard
Stevens "Unix Network Programming" or Marc Rochkind's "Advanced Unix Programming" for
code examples on how to do this.

-- 
- Randy Bullard  -    Dallas, TX randy@rss.dl.nec.com
					  Home (214)750-4934
					  Work (214)907-4463

| Have you ever rubbed your thigh with number 10 sandpaper and     |
| poured Red Devil turpentine on it?  I hate it when that happens. |
Xref: sparky comp.unix.programmer:2402 comp.unix.internals:1120 comp.unix.wizards:2215
From: charette@cheetah.det.dec.com (Mark Charette)
Newsgroups: comp.unix.programmer,comp.unix.internals,comp.unix.wizards
Subject: Re: What is the system call for microsecond sleep?
Date: 15 Apr 92 18:10:55 GMT
Reply-To: charette@cheetah.det.dec.com (Mark Charette)
Organization: Digital Equipment Corporation


In article <1992Apr13.223115.22899@gateway.novell.com>, terry@ithaca.npd.Novell.COM (Terry Lambert) writes:
|>In article <1992Apr10.204412.20045@lambda.msfc.nasa.gov>, mahmood@lambda.msfc.nasa.gov (Rafique Mahmood) writes:
|>|> I am developing some portable code in which I need to use microsecond
                          ^^^^^^^^
This is a problem - microsecond resolution timing is not yet portable.   
|>|> sleep. So, I used usleep(microsecond) system call. The problem is Decstation
|>|> does not support this call. They have 'napms(milisec)'.
|>
|>	Write it for a system with a system clock resoloution greater than or equal to 1 uSec.  The
|>DECStation is 10 uSec.  The closest you will ever get is +/- 10 uSec.  The VAXStation is worse by a
|>factor of 3.  You could use a timeout on the poll() or select() system calls if you can live with this
|>resoloution.  If you can't, get a faster box ;-).

Timer resolution is a factor of a timer, not the box (if cpu is what you meant).
If you need better resolution for the timer, ask for a better timer.
--
Mark Charette                |Yes, I do speak for my employer. Really. Often.
Fisher Engineering Systems   |Digital Equipment Corporation is NOT my employer,
charette@cheetah.det.dec.com |so don't blame them. I just consult there.