HDTenEightyP/NetNews huggingface dataset:
From: chet@odin.INS.CWRU.Edu (Chet Ramey)
Newsgroups: comp.unix.programmer
Subject: Re: recursively moving to directories
Date: 13 Apr 92 20:13:12 GMT
Article-I.D.: usenet.1992Apr13.201312.15424
Organization: Case Western Reserve University

In article <1992Apr13.023723.7892@cbr.dwr.csiro.au> marcus@cbr.dwr.csiro.au (Marcus Schnell) writes:

>I want to change ownership of EVERYTHING in the current directory
>recursively, files as well as subdirectories.

Without chown -R, use find piped to xargs.

find . -print | xargs /etc/chown foo

I have a shell function to do this kind of thing (that I actually haven't
used in some time :-).

tw ()
{
	dir=$1 ; shift
	cmd=$1 ; shift
	find "$dir" -print | xargs "$cmd" "$@"
}

use it like "tw . /etc/chown foo".

Chet

-- 
``The use of history as therapy means the corruption of history as history.''
	-- Arthur Schlesinger

Chet Ramey, Case Western Reserve University	Internet: chet@po.CWRU.Edu
Xref: sparky comp.unix.programmer:2283 comp.lang.c:7372
From: guy@Auspex.COM (Guy Harris)
Newsgroups: comp.unix.programmer,comp.lang.c
Subject: Re: How to write the ANSI C time functions
Date: 8 Apr 92 19:06:13 GMT
Followup-To: comp.unix.programmer
Organization: Auspex Systems, Santa Clara

>So the C standard clearly *is*
>calling for leap seconds to be respected.

*I* just see it as *allowing* leap seconds to be respected, but since it
doesn't explicitly say "leap seconds are respected", I don't see it as
"calling for" them to be respected in the sense of "requiring them to be
respected".

I.e., an implementation that does respect leap seconds, and an
implementation that does not, can both be ANSI C-conformant.  An
implementation that respects them *cannot* be POSIX 1003.1-conformant;
an implementation that does not can.

(I wish POSIX 1003.1 *had* required them to be respected; the rationale
for not doing so cuts no ice with me, and there even exists a
*freely-available and freely-redistributable* UNIX implementation that
does respect them, thanx to Arthur Olson and Bradley White. 
Unfortunately, the damage has already been done....)
From: jik@athena.mit.edu (Jonathan I. Kamens)
Newsgroups: comp.unix.programmer
Subject: Re: How to get the return status of a finished process
Date: 10 Apr 92 13:34:52 GMT
Article-I.D.: pit-mana.JIK.92Apr10093446
Organization: Massachusetts Institute of Technology

If you're writing a program that invokes other processes, then I hope
you know that you have to use wait() (or wait3() or wait4() or
whatever) to wait for those processes when they are done.  Note that
the return from wait() includes the exit value of the process, as well
as whether it was killed, aborted, or whatever.

For more information about this, see the comp.unix.questions FAQ
postings, which discuss wait()ing for children that have finished
running.

-- 
Jonathan Kamens						jik@MIT.Edu
MIT Information Systems/Athena		    Moderator, news.answers
    (Send correspondence related to the news.answers newsgroup
	{and ONLY correspondence related to the newsgroup}
		 to news-answers-request@MIT.Edu.)
Newsgroups: comp.unix.programmer
From: peter@ferranti.com (Peter da Silva)
Subject: Re: Elegant mass file renamer
Organization: Xenix Support, FICC
Date: Wed, 8 Apr 1992 19:41:34 GMT

In article <1992Apr6.082205.3979@lth.se> bengtl@maths.lth.se (Bengt Larsson) writes:
> >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.

Well, that's the point. I run this sort of interactive loop all the time.
Just toss 'em off, either in csh (foreach) or in sh (for).

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

No, it was my example because it was the case brought up by this discussion.

> >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 haven't written "rename" either. I write loops.

I *did* snarf a general "rename" program from somewhere a few years back,
but I found I was using it so infrequently I didn't bother adding it to
my "must have" toolbox. As I recall, it did have a more general syntax along
the lines of the one I suggested above.

> 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?

Neither. I never *claimed* it was a working program. I said the solution
"would be along the lines of" the code I wrote. If I'd packaged it up as
a shell archive and posted it to alt.sources you'd have a valid complaint.
Discussion groups are for discussion, not code distribution.
-- 
/F{/Times-Roman findfont exch scalefont setfont}def /M{moveto}def /S{show}def
8 F 24 24 M (Sugar Land, TX  77487-5012; +1 713 274 5180)S 60 0 rmoveto(`-_-')S
12 F 24 32 M (Peter da Silva, Ferranti International Controls Corporation)S
0 -6 rmoveto 20 F ( Have you hugged your wolf today?)S showpage
Newsgroups: comp.unix.programmer
From: subbarao@phoenix.Princeton.EDU (Kartik Subbarao)
Subject: Re: sockets
Organization: putchar('I'); for (i = 0; i < 3; i++) putchar('E');
Date: Mon, 13 Apr 1992 22:50:06 GMT

In article <kujt79INN83v@early-bird.think.com> barmar@think.com (Barry Margolin) writes:

>>Can anyone PLEAAAASEE tell me how to connect two sockets?
>
>You mentioned the word in your very question: use the connect() call.
>
>>  s1 = socket(PF_UNIX, SOCK_STREAM, 0);
>>  s2 = socket(PF_UNIX, SOCK_STREAM, 0);
>
>Call one of them the server and the other the client.  You use bind() on
>the server socket to give it a name and then listen() to inform the system
>that it should accept connections for that name.  Then you can call
>connect() on the client socket, specifying the same name, and accept() on
>the server socket.

Aww, come on, Barry. It takes *one* system call to do just what he wants,
to create 2 sockets connected to each other. socketpair().

int s[2];
socketpair(PF_UNIX, SOCK_STREAM, 0, s);

That's all folks.

	-Kartik

Newsgroups: comp.unix.programmer
From: mmoore%peruvian.utah.edu@cs.utah.edu (Michael Moore)
Subject: simple input redirection
Date: 13 Apr 92 22:41:52 MDT
Reply-To: mmoore%peruvian.utah.edu@cs.utah.edu
Organization: University of Utah, CS Dept., Salt Lake City

	Thank you to all who helped me with my earlier problem.  Now I
have another more devious problem which I hope someone out there can solve
for me!

	All I want do is spawn a child process who's stdin I can write
to through a socket.

	You'd think this would be simple, but I'm either screwing it up
again (which is possible) or the operating system is not conforming to 
BSD Unix requirements.

	I add the latter because I have personally seen socket code that
worked on SunOS 4.1.2 but did not work on IBM AIX 3.1.5!

	Anyway, this is what I am doing, and it is not working.  

--------------------------------------------------------------------
int fds[2],rc;
int pid;

pid = fork();
if (!pid) {
  rc = socketpair(AF_UNIX, SOCK_STREAM, 0, fds);
  if (rc < 0)
    Error("Cannot create socketpair");
  if (fcntl(fds[0], F_SETOWN, getpid()) < 0)
    Error("Cannot F_SETOWN");
  if (fcntl(fds[0], F_SETFL, FNDELAY | FAPPEND) < 0)
    Error("Cannot F_SETFL to FNDELAY and FAPPEND");
  close(fileno(stdin));
  dup(fds[0]);
  execlp("/u/mmoore/itest", "itest", (char *) 0);
  printf("did not exec.\n");
  exit(0);
}
fprintf(fds[0], "Hello world.\n");
fprintf(fds[0], "Can you hear me!\n");
fprintf(fds[0], "Why the @#&^&*# can't you hear me!\n");
---------------------------------------------------------------------
all itest does is print a greeting and print out what it reads from stdin.
It works just fine when I run itest alone, but doing it this way it never
gets my input!

	Please, can someone tell me what I am doing wrong?  At the least,
can someone give a difinitive answer as to whether or not this is an
AIX problem?

	-Thanks for any help, 

	Michael
From: jc@minya.UUCP (John Chambers)
Newsgroups: comp.unix.programmer
Subject: Re: Help: How to kill the child when the parent dies ?
Date: 6 Apr 92 02:51:20 GMT

> :  I am asking help for the problem described in the subject line, 
> : which appears in an application I worte. The parent program forks 
> : out a few children and communicates with them through pipe.  Everything 
> : works fine and the parent kills the children in its normal exit. 
> : I wonder if there is some mechanism such as signal that can kill the 
> : children automatically even when the parent dies abnormally (such as 
> : on SEGV).
>
> One of the ways that I handle this case is to create  pipes  between
> the  parents  and the children, configured for writing on the parent
> side, and reading on the child side and in async mode. In each child
> I  setup a signal handler for SIGPIPE.  No data need be passed using
> this pipe.
>
> When the parent terminates, a  SIGPIPE  will  be  generated  in  the
> children, who can then cleanup and terminate.

This  works  if  you  are the author of both the parent and child, but
I've run across this problem at work in  a  situation  where  I  can't
really  modify the child.  The situation is an application (running on
Ultrix) that needs to connect to another system and talk to a  program
that expects to talk to a remote "user". The obvious thing is to start
up rlogin or dlogin or telnet as a subprocess, and talk to it  through
pipes.   This  works fine.  But if the parent dies, all three of these
remote-login program show the same unpleasant  behavior:   They  don't
recognize  the  parent's  death,  or the 0 that they get from reads as
meand EOF.  They go into an infinite loop, eating up the cpu, until  a
human  comes  along  and wonders why the machine is so slow, and kills
them.

One solution, obviously, is to write the parent  so  that  it  doesn't
have  any  bugs, and never bombs out.  But even if this were feasible,
there is the problem that many users "know" that the way to kill of  a
program  is  to  use  "kill  -9",  and  in  that  case, all my perfect
programming is to no avail whatsoever.

So. Does anyone know a way that a parent can set things up so that, if
it dies, its children will also be killed? I've been working with Unix
for about a decade now, and I've never seen a clue that it's possible.
But it sure would be useful.
From: rrybacki@ringer.cs.utsa.edu (Richard M. Rybacki)
Newsgroups: comp.unix.programmer
Subject: Re: Need help writing Front End
Keywords: Front-End stdin stdout
Date: 6 Apr 92 21:02:39 GMT
Organization: University of Texas at San Antonio

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?

-- 
Richard M. Rybacki                |     Happiness = Reality - Expectations
rrybacki@ringer.cs.utsa.edu       |     -- Click & Clack, The Tappet Brothers
From: aspect@sun1g.informatik.Uni-Bremen.DE (ASpecT (=jvh+ric))
Newsgroups: comp.unix.programmer
Subject: How to get the return status of a finished process
Date: 10 Apr 92 10:07:43 GMT
Organization: Universitaet Bremen


I'm currently writing a special make tool which is able to
use a given list of connected machines which can be used in
parallel. The tool forks processes which do an execve to 
change to a little program having the task to rsh the job to other
machines. Now I have the problem that the main tool has to
check if one of these processes (i.e. a C compiler run) fails.

A naive solution lets the 'rsh-submitting' process create a file
containing the return-status - a solution I do not like very
much.

Any advices gratefully accepting
--Joern 
Newsgroups: comp.unix.programmer
From: marcus@cbr.dwr.csiro.au (Marcus Schnell)
Subject: Re: recursively moving to directories
Organization: CSIRO Division of Water Resources
Date: Mon, 13 Apr 1992 02:37:23 GMT

eigenstr@nyssa.cs.rose-hulman.edu (Todd R. Eigenschink) writes:
: In article <1992Apr7.004137.10446@cbr.dwr.csiro.au> marcus@cbr.dwr.csiro.au (Marcus Schnell) writes:
: 
:    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.
: 
[stuff deleted]

: Boy, this one's easy!  (Unless I'm misunderstanding something... :)
: 
: 	chown -R new-owner starting-path
: 
: That will change ownership of all files and directories.  If you

Yes you are misunderstanding, problem is: my chown has NO -R option...

: _just_ want to change file ownerships, I believe this is what you
: want:
: 

I want to change ownership of EVERYTHING in the current directory
recursively, files as well as subdirectories.


****************************************************************************
*    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: jik@athena.mit.edu (Jonathan I. Kamens)
Subject: Re: sleep and alarm
Organization: Massachusetts Institute of Technology
Date: Thu, 9 Apr 1992 21:55:56 GMT

In article <1992Apr8.130101.2113@descartes.waterloo.edu> bbobak@descartes.waterloo.edu (Brad Bobak) writes:

    Hi all. I have a question about sleep and alarm that I was wondering if you
   could answer for me. In the man pages, sleep sez:

						       ...The actual
	suspension time may be an arbitrary amount longer because of
	other activity in the system.

    Was wondering if this is true for alarm also?

Yes.

UNIX (or, at least, most variants of UNIX) is not a real-time
operating system.  Events are not guaranteed to occur precisely when
you expect them.

-- 
Jonathan Kamens						jik@MIT.Edu
MIT Information Systems/Athena		    Moderator, news.answers
    (Send correspondence related to the news.answers newsgroup
	{and ONLY correspondence related to the newsgroup}
		 to news-answers-request@MIT.Edu.)
From: ihno@generics.ka.sub.org (Ihno Krumreich)
Newsgroups: comp.unix.programmer
Subject: Re: Lost: an interesting hack
Date: 15 Apr 92 17:45:53 GMT
Organization: Generics GmbH

Look at the sources of emacs. The build in lisp functions are initialized in
this manner. Another example is TeX.

Ihno
-- 
Ihno Krumreich     | Phone (49) 721 38 70 94
Generics Gmbh      | email: ihno@generics.ka.sub.org
Breite Strasse 24  | FAX   (49) 721 38 56 22
D-W7500 Karlsruhe  |
Newsgroups: comp.unix.programmer
From: adrienne@nodecg.ncc.telecomwa.oz.au (adrienne byrd 4208172)
Subject: Reading from stdin then write to stdout when possible
Organization: Network Computer Centre
Date: Tue, 14 Apr 1992 00:34:45 GMT

Help !  I'm getting more confused by the minute and I thought this would be
"simple."  (I've only just started at C programming, perhaps that will
become obvious.)

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.

The command line will look like: 
	inout <inpipe >outpipe

I have tried :
	#include <stdio.h>

	main(argc,argv)
	int argc;
	char **argv;
	{
		int iRCnt,
			iWCnt;
		char *buf;
		int bufsize = BUFSIZ;	/* 1024 */

		/* do both reads and writes only while the writes are successful...*/

		while ((iRCnt = fread(buf,1,bufsize,stdin)) > 0)
		{
			fprintf(stderr,"read from stdin...\n");
			if ( !ferror(stdout) & !feof(stdout) )
			{
				fprintf(stderr,"...about to write...\n");
				fwrite(buf,1,iRCnt,stdout);
			}
			else
				clearerr(stdout);
		}

		return(0);
	}

and am testing it with:
	inout <inpipe >outpipe 2>log

	where I spew characters into inpipe and then also 'cat < outpipe'.

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).

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.

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.

I'm running Xenix 2.3, if it matters.

Thanks to anyone and all who can help me in advance...

     _--_|\     Adrienne Byrd             ph: +61 9 4208172
    /      \    Network Computer Centre   adrienne@telecomwa.oz.au
--> *_.--._/    5/80 Stirling Street
          v     Perth 6000, Western Australia
From: schwartz@roke.cs.psu.edu (Scott Schwartz)
Newsgroups: comp.unix.programmer
Subject: Re: recursively moving to directories
Date: 17 Apr 92 20:10:05 GMT
	<1992Apr13.023723.7892@cbr.dwr.csiro.au>
	<1992Apr13.201312.15424@usenet.ins.cwru.edu> <4r9Hctyp6@cs.psu.edu>
	<1992Apr16.040513.10313@siia.mv.com>
Organization: penn state university, computer science

drd@siia.mv.com (David Dick) writes:
   If you don't worry so much about the efficiency of forking chown
   for every file, you can just find . -exec chown {} \;

Yup.  I wish this kind of thing were efficient enough so no one needed
to ever worry about it.  Wouldn't it be nice if any a.out could call
functions contained within any other a.out?  We have
/bin/chown::main() in this case, but /bin/sh::glob() would be handy
pretty often.  It's probably doable now with dynamic libraries and a
disciplined rewrite of all existing utilities.  :-)
Newsgroups: comp.unix.programmer
From: dkeisen@leland.Stanford.EDU (Dave Eisen)
Subject: Re: Re : non-blocking accept()
Organization: Sequoia Peripherals, Inc.
Date: Fri, 10 Apr 92 23:14:47 GMT

In article <FRANL.92Apr10121115@draco.centerline.com> franl@centerline.com (Fran Litterio) writes:
>
>Is it worth pointing out that select() is not part of Posix.1, so by
>using it you run the risk that your code will not port to some pure
>System V/Posix.1 machines?  Just how many systems don't provide
>select() anyway?

SCO Xenix has it. But it was added very recently, I think it was added
in the last release. So a lot of drivers don't understand it and I
wouldn't feel comfortable using it unless I knew where the file 
descriptor came from.



-- 
Dave Eisen    dkeisen@leland.Stanford.EDU   Sequoia Peripherals: (415) 967-5644
      There's something in my library to offend everybody.
        --- Washington Coalition Against Censorship
Xref: sparky comp.unix.programmer:2414 comp.std.c:1829
From: guy@Auspex.COM (Guy Harris)
Newsgroups: comp.unix.programmer,comp.std.c
Subject: Re: How to write the ANSI C time functions
Date: 15 Apr 92 22:09:29 GMT
Followup-To: comp.std.c
Organization: Auspex Systems, Santa Clara

>It doesn't explicitly say "leap years are respected" either!  It doesn't
>have to.  Leap seconds, like leap years, are now built into our calendar;

Yes, but they're not built into most UNIX systems, whence "localtime()"
and company came, so:

>the standard would have to explicitly say if they *weren't* respected.

whether it would have to explicitly say they're not respected, or
whether they are respected, depends on whether you consider UNIX
implementations, or the calendar, to be what lies behind the 1984
"/usr/group" standard cited as a base document (I don't have the
"/usr/group" standard handy, so I don't know if it speaks of leap
seconds or not).

Or, in other words, you can assert all you want that the ANSI C standard
requires that leap seconds be honored - and, believe me, I'd be
overjoyed if it did, as it'd have whipped the POSIX folks into line -
but I ain't gonna believe those assertions until an official
interpretation comes from the ANSI C committee, or somebody finds
something in the 1984 "/usr/group" standard that requires it (in which
case somebody should ask the POSIX committee how that requirement
managed to disappear).

(Hence the redirection to "comp.std.c".  I suspect it won't provoke a
ruling, but it might provoke somebody with more CFT than I to write in
and request one....)
From: sium@syma.sussex.ac.uk (Siu Mak)
Newsgroups: comp.unix.programmer
Subject: Re: Two Questions
Date: 15 Apr 92 18:34:01 GMT
Organization: University of Sussex at Brighton

In article <1992Apr13.153121.11537@alias.com>, bmcgowan@alias.com (Brian MacGowan) writes:
> Hi, I am new to C programming and I 2 hopefully simple questions.
> 1) How can I simulate the find command. I need to search a directory and all of
>    its subdirectories for various filenames.
>
> 2) Using curses if I have more data than can fit in a window, can I scroll the
>    text up and down.
>
> Any help with these 2 problems would be most appreciated.
>
> Thanks
>
> - Brian MacGowan, Alias Research Inc, Toronto - bmcgowan@alias.com
>


2) <- answer

You may fit data in a pad and just display a part of it.
Of course, you can scroll text up or down through pad.
Pad is a structure like windows, defined in curses library.
Organization: Old Dominion University
Date: Thursday, 9 Apr 1992 17:21:40 EDT
From: Pam Skillman <PJS100T@ODUVM.BITNET>
Newsgroups: comp.unix.programmer
Subject:    Re : non-blocking accept()

Another alternative provided in 4.3BSD is the select system call.  This is
the preferred method (I believe).  This allows the process to instruct the
kernel to wait for any one of multiple events to occur and to wake up the
process only when one of these events occurs (ie.  only when data is avail-
able to be read from any of the input sources).

#include <sys/types.h>
#include <sys/time.h>

int select(int maxfdpl, fd_set *readfds, fd_set *writefds, fd_set *exceptfds,
           struct timeval *timeout);

FD_ZERO(fd_set *fdset);    /*  clear all bits in fdset  */
FD_SET(int fd, fd_set *fdset);   /*  turn the bit for fd on in fdset  */
FD_CLR(int fd, fd_set *fdset);   /*  turn the bit for fd off in fdset  */
FD_ISSET(int fd, fd_set *fdset); /*  test the bit for fd in fdset  */

structure pointed to by timout arg :
  struct timeval {
    long   tv_sec;      /* seconds */
    long   tv_usec;     /* microseconds */
};

Can be set to monitor for reading, writing and exceptional conditions.
The timeout argument can have 3 different conditions:

1.  Return immediately after checking the descriptors (polling).  The
timeout arg must point to a timeval struc and the timer value (seconds and/or
microseconds) must be zero.

2.  Return when one of the specified descriptors is ready for I/O, but don't
wait beyond a fixed amount of time.  timer value should be nonzero.

3.  Return only when one of the specified descriptors is ready for I/O.
Timeout arg must be NULL.  (Blocking).  Can be interrupted with a signal.

I hope this has been helpful and you are able to use it.

Pam Skillman
Old Dominion University
Computer Services
Technical Support Group
Newsgroups: comp.unix.programmer