Mail Delivery Problem

SMTP MAILER postmaster at sandia.gov
Mon Aug 20 00:43:38 AEST 1990


 ----Reason for mail failure follows----
Sending mail to <math!ckaul at cs.sandia.gov> :
  Could not be delivered for three days.

 ----Transcript of message follows----
Date: 16 Aug 90 05:36:00 MDT
From: unix-wizards at BRL.MIL
Subject: UNIX-WIZARDS Digest  V10#118
To: "math!ckaul" <math!ckaul at cs.sandia.gov>

Return-Path: <incoming-unix-wizards-request at sandia.gov>
Received: from SEM.BRL.MIL by sandia.gov with SMTP ; 
          Thu, 16 Aug 90 05:22:53 MDT
Received: from SEM.BRL.MIL by SEM.BRL.MIL id aa21242; 16 Aug 90 5:57 EDT
Received: from sem.brl.mil by SEM.BRL.MIL id aa21187; 16 Aug 90 5:45 EDT
Date:       Thu, 16 Aug 90 05:45:08 EST
From:       The Moderator (Mike Muuss) <Unix-Wizards-Request at BRL.MIL>
To:         UNIX-WIZARDS at BRL.MIL
Reply-To:   UNIX-WIZARDS at BRL.MIL
Subject:    UNIX-WIZARDS Digest  V10#118
Message-ID:  <9008160545.aa21187 at SEM.BRL.MIL>

UNIX-WIZARDS Digest          Thu, 16 Aug 1990              V10#118

Today's Topics:
                Re: evaluating ${10} and above in sh/ksh
                       Re: csh weirdness (HELP!)
                           Re: waitpid() ???
                 Re: Cron - First Saturday of the month
                     Re: Please add me to User list
         AT&T 3B2, PC-NFS, Curses - reverse video with werase()
                   Re: sendmail config file question
                        Re: Is HDB locking safe?
                         Broadcast UDP packets
                          shmat() system call?
                        Re: shmat() system call?
                          Re: Curses question
               Re: Another "why won't this work" program
                    How to restrict commands in rsh?
                          Vi fails on a Sun-4
                         Directory compression

-----------------------------------------------------------------

From: Bob Desinger <bd at hpopd.hp.com>
Subject: Re: evaluating ${10} and above in sh/ksh
Date: 14 Aug 90 15:35:15 GMT
To:       unix-wizards at sem.brl.mil

> There doesn't seem to be a way, in sh or ksh, to evaluate $10 and higher.

In /bin/sh this never worked, although individual vendors may have
modified their /bin/sh.  I don't know of any that have, by the way.

It looks like your ksh is broken.  Version 06/03/86 (or at least that
version shipped with HP-UX at 7.0 on Series 300 and 800) does the
right thing:

    set a b c d e f g h i j k l

    print 9 is $9, 10 is ${10}, 11 is ${11}, 12 is ${12}.

    alias i='echo Number 9'
    alias j='echo Number 10'
    alias k='echo Number 11'
    alias l='echo Number 12'
    eval $9
    eval ${10}
    eval ${11}
    eval ${12}
	
The new ksh88, Version 11/16/88, also does the right thing.  Both
versions of ksh generate the correct output:

    9 is i, 10 is j, 11 is k, 12 is l.
    Number 9
    Number 10
    Number 11
    Number 12

I invoked the script with `ksh script' and `ksh88 script'.   Then I
also tested it with a first line of `#! /usr/local/bin/ksh88' and
`#! /bin/ksh'.  All four cases generated the same output.  Uh, ksh88
isn't shipped with HP-UX; we bought it from the AT&T Toolchest.

Your script lines are considerably more complex than mine, though.  In
fact, I stopped trying to figure out what the script was trying to do
and just ran your script.  I mailed my output to you; we can follow
this up offline.  Summarize to the net?

-- bd

-----------------------------

From: Bob Desinger <bd at hpopd.hp.com>
Subject: Re: csh weirdness (HELP!)
Date: 14 Aug 90 15:49:12 GMT
To:       unix-wizards at sem.brl.mil

> to kill every instance of a.out I get
> 	`ps | grep a.out | awk '{printf("%d ",$1);}'`: Ambiguous.

Can you work around this by changing the awk program to generate the
kill commands, then piping the awk output to the shell?  As in:

    ps | grep a.out | awk '{print "kill", $1}' | sh

-- bd

-----------------------------

From: Dave Decot <decot at hpisod2.cup.hp.com>
Subject: Re: waitpid() ???
Date: 15 Aug 90 00:26:26 GMT
To:       unix-wizards at sem.brl.mil

> >Does anyone have an idea exactly what [waitpid()] does?
> 
> waitpid() is a POSIX function:
> 
> 	int waitpid(int pid, int *status, int options)
> 
> where the `pid' argument is the process ID of the process to wait
> for, or WAIT_ANY to wait for any child;

WAIT_ANY does not exist in POSIX.  The correct value to wait for any child
is -1.

Dave Decot

-----------------------------

From: Steve Alter <alter at ttidca.tti.com>
Subject: Re: Cron - First Saturday of the month
Date: 15 Aug 90 01:46:48 GMT
To:       unix-wizards at sem.brl.mil

In article <19744 at orstcs.CS.ORST.EDU> curt at oce.orst.edu (Curt Vandetta) writes:
}   I'm wondering if anyone has a way of making cron run a job on the
}   first Saturday of every month?  

I'm going to totally side-step the fight that has been waged over
whether the day-of-week is logically ANDed or ORed with the day-of-month.

You can set it up using a combination of cron and "at".

For example, let's assume that you want the job to run at 1 a.m. on
the first Saturday of each month.  You put in a cron job to run at
12:30 a.m. on the 1st DAY of each month, and have that cron job
launch an "at" job to run at 1 a.m. on the next Saturday, which could
be as soon as 30 minutes later.  Tweak the names and numbers to your
heart's delight, but the concept remains.

The cron line (SunOS 4.x):

30 0 1 * *   /home/myacct/bin/next.Saturday

The next.Saturday script (mode 755):

at -c 0100 Sat first.Saturday.of.month

File "first.Saturday.of.month" contains... oh, you can figure it out.

-- 
Steve Alter        <alter at ttidca.tti.com>
{csun,philabs,psivax,pyramid,quad1,rdlvax,retix}!ttidca!alter
Citicorp/TTI, Santa Monica CA  (213) 450-9111 x2541

-----------------------------

From: Dave Corcoran <dave at aspect.uucp>
Subject: Re: Cron - First Saturday of the month
Date: 15 Aug 90 13:38:07 GMT
To:       unix-wizards at sem.brl.mil

In article <1990Aug11.030818.28876 at watserv1.waterloo.edu>, dmcanzi at watserv1.waterloo.edu (David Canzi) writes:

> This is better done using awk:
> 
> if [ `date | awk '{print $3}'` -le 7 ]; then

or:

if [ `date +%d` -le 7 ]


-- 
David Corcoran		-@@
uunet!aspect!dave	  ~
Good, fast, cheap; pick any two.

-----------------------------

From: B|rje Josefsson <bj at dc.luth.se>
Subject: Re: Cron - First Saturday of the month
Date: 15 Aug 90 17:26:59 GMT
To:       unix-wizards at sem.brl.mil

Slightly a side question according to the Subject:, but how to setup a
command for execution on the LAST day of the month ONLY? 

I could use:
            0 0 31 1 * command
            0 0 28 2 * command
            0 0 31 3 * command
            and so on
but that will not work on leap years...

--Borje
 -----------------------------------------------------------------------------
Borje Josefsson, Computer centre, University of Lulea, S-951 87 Lulea, Sweden
Tel: +46 920 91 262 (direct), +46 920 91 000 (operator).  Fax: +46 920 972 88

Domain:  bj at dc.luth.se                Path: {uunet,mcsun,sunic}!dc.luth.se!bj

-----------------------------

From: Christopher R Volpe <volpe at underdog.crd.ge.com>
Subject: Re: Cron - First Saturday of the month
Date: 15 Aug 90 20:57:54 GMT
Sender: news at crdgw1.crd.ge.com
To:       unix-wizards at sem.brl.mil

In article <1489 at hagbard.dc.luth.se>, bj at dc.luth.se (B|rje Josefsson) writes:
|>Slightly a side question according to the Subject:, but how to setup a
|>command for execution on the LAST day of the month ONLY? 
|>
|>I could use:
|>            0 0 31 1 * command
|>            0 0 28 2 * command
|>            0 0 31 3 * command
|>            and so on
|>but that will not work on leap years...
|>
|>--Borje

Set the date on your machine to one day ahead of the real date, and tell
cron to run your application on the first of each month. ( 1/2 :-) )
                
==================
Chris Volpe
G.E. Corporate R&D
volpecr at crd.ge.com

-----------------------------

From: Larry Wall <lwall at jpl-devvax.jpl.nasa.gov>
Subject: Re: Cron - First Saturday of the month
Date: 15 Aug 90 23:14:42 GMT
To:       unix-wizards at sem.brl.mil

In article <1489 at hagbard.dc.luth.se> bj at dc.luth.se (B|rje Josefsson) writes:
: Slightly a side question according to the Subject:, but how to setup a
: command for execution on the LAST day of the month ONLY? 
: 
: I could use:
:             0 0 31 1 * command
:             0 0 28 2 * command
:             0 0 31 3 * command
:             and so on
: but that will not work on leap years...

I'd suggest (surprise, surprise)

    0 0 * * * perl -e '(localtime(time + 24*60*60))[3] == 1 && exec "command"'

or, more concisely

    0 0 * * * perl -e 'exit+(localtime time+86400)[3]-1' && command

Larry Wall
lwall at jpl-devvax.jpl.nasa.gov

-----------------------------

From: David Canzi <dmcanzi at watserv1.waterloo.edu>
Subject: Re: Cron - First Saturday of the month
Date: 16 Aug 90 00:22:29 GMT
To:       unix-wizards at sem.brl.mil

In article <3706 at aspect.UUCP> dave at aspect.UUCP (Dave Corcoran) writes:
>In article <1990Aug11.030818.28876 at watserv1.waterloo.edu>, dmcanzi at watserv1.waterloo.edu (David Canzi) writes:
>> if [ `date | awk '{print $3}'` -le 7 ]; then
>
>or:
>if [ `date +%d` -le 7 ]

This doesn't work on all the machines I have access to, so I prefer
the solution using awk.

-- 
David Canzi

-----------------------------

From: "LCDR Michael E. Dobson" <rdc30med at nmrdc1.nmrdc.nnmc.navy.mil>
Subject: Re: Please add me to User list
Date: 15 Aug 90 13:02:42 GMT
To:       unix-wizards at sem.brl.mil

Periodicly we see these types of messages appearing in the various news groups
that also include gatewayed mailing lists.  This is generaly caused by two
mechanisms.  The first is posting the request to the gatewayed mailing list,
ie info-unix at sem.brl.mil or unix-wizards at sem.brl.mil, instead of the
administrative list, ie info-unix-request at sem.brl.mil.  This is due to ignorance
on the  part of the person trying to get on the list (they may not have news
on their system).  The second and more serious reason is the request mail
address being incorrectly gatewayed into the newsgroup.  If this is happening,
flames should be directed to the list maintainer, not the poor user who has no
control over how his message is treated once it reaches the mail gateway system.
-- 
Mike Dobson, Sys Admin for      | Internet: rdc30med at nmrdc1.nmrdc.nnmc.navy.mil
nmrdc1.nmrdc.nnmc.navy.mil      | UUCP:   ...uunet!mimsy!nmrdc1!rdc30med
AT&T 3B2/600G Sys V R 3.2.2     | BITNET:   dobson at usuhsb.bitnet
WIN/TCP for 3B2                 | MCI-Mail: 377-2719 or 0003772719 at mcimail.com

-----------------------------

From: Grant Grundler <grant at pescara.orc.olivetti.com>
Subject: Re: Please add me to User list
Date: 15 Aug 90 17:17:16 GMT
Control: cancel <49280 at ricerca.UUCP>
Sender: news at orc.olivetti.com
To:       unix-wizards at sem.brl.mil


-----------------------------

From: Guy Harris <guy at auspex.auspex.com>
Subject: Re: Please add me to User list
Date: 15 Aug 90 17:35:13 GMT
To:       unix-wizards at sem.brl.mil

>Looks like the somebody needs to learn how to use "rn"!

No, somebody just needs to have the protocol for joining/leaving mailing
lists explained to them before being told about those mailing lists. 
There's no guarantee that his machine necessarily *gets* netnews; if it
doesn't, "rn" (or any other newsreader) won't do him a lot of good....

-----------------------------

From: dxg at cai.com
Subject: AT&T 3B2, PC-NFS, Curses - reverse video with werase()
Keywords: ATT 3B2, PC-NFS, CURSES
Date: 15 Aug 90 14:12:17 GMT
To:       unix-wizards at sem.brl.mil


/**********************************************************************
 *
 * I am using PC-NFS Version 3.0 to connect to an AT&T 3B2 running UNIX
 * System V Release 3.2.1.  My environment variable TERM is 'vt100'.
 *
 * I am developing a large application using Curses and have run into
 * a problem.  I have to output a string to a window, in reverse video
 * and then clear this window.  But for some reason when the window
 * is cleared the row that contains the reverse video character(s)
 * and all the rows that follow are cleared (output) in reverse video.
 *
 * This problem occurs when the last character output is in reverse video.
 *
 * The problem does not occur, if the last non-blank character output is
 * not in reverse video.
 *
 * The following source file is a small scale version of the problem.
 *
 * The compile command that I am using is:
 *   cc $*.c -o $* -lm -lcurses
 *
 * Please let me know how I can work around this problem, or what I
 * am doing wrong.
 *
 * Thanks,
 * Constantine "Dean" Grammas
 * Computer Associates International
 * 201 University Avenue
 * Westwood MA, 02090
 * (617) 329-7700 x3314
 *
 */

/*********************
**** TEST ROUTINE ****
**********************/
#include	<curses.h>

/*
* Repaint the the specified window
*/
rep_win( wid )
	WINDOW *wid;
{
	/* just for arguments sake, turn off the reverse video attribute
	 */
	wattroff( wid, A_REVERSE );

	wnoutrefresh( wid );
	touchwin( wid );
	doupdate();
} /* END rep_win */

/*
* Repaint the specified window and wait for a key stroke
*/
get_key( wid )
	WINDOW *wid;
{
	/* just for arguments sake, turn off the reverse video attribute
	 */
	wattroff( wid, A_REVERSE );

	rep_win( wid );
	beep();
	wgetch( wid );
} /* END get_key */

/*
* Clear the specified window and then repaint it
*/
clr_win( wid )
	WINDOW *wid;
{
	/* just for arguments sake, turn off the reverse video attribute
	 */
	wattroff( wid, A_REVERSE );

	werase( wid );
	rep_win( wid );
} /* END clr_win */

main()
{
	WINDOW *wid;

	stdscr = initscr();

	/* output a line of text in reverse video, and wait for a key stroke
	 */
	wattrset( stdscr, A_REVERSE );
	mvwaddstr( stdscr, 10,10, "Press any key." );
	wattroff( stdscr, A_REVERSE );
	wattrset( stdscr, A_NORMAL );
	get_key( stdscr );

	/* clear the window, and wait for a keystroke
	 *
	 * NOTE: this is where the problem occurs.
	 */
	wattrset( stdscr, A_NORMAL );
	clr_win( stdscr );
	get_key( stdscr );
	endwin();
} /* END main */

-----------------------------

From: MSHAW at wl9.prime.com
Subject: Re: sendmail config file question
Date: 15 Aug 90 14:49:00 GMT
Nf-ID: #R:sparkyfs.istc.sri.com:-3255900:WL9:16300003:000:2301
Nf-From: WL9.Prime.COM!MSHAW    Aug 15 14:49:00 1990
To:       unix-wizards at sem.brl.mil


I'm not a sendmail guru yet but here's my help anyway.

To recap you put.....

| We're getting ready to change our domain name, and I want to make sendmail
| clever enough to handle mapping the old domain to the new one.  Problem is,
| we're already doing that from the domain name of about a year ago.
|
| Basically, right now I have:
|
| DDitstd.sri.com                         current domain name
| DEistc.sri.com                          old domain name
|
| S1
| R$*<@$-.$E>$*         $1<@$2.$D>$3      change domain name
| R$*<@$E>$*            $1<@$D>$2         change domain name
|
| and likewise for S2.  Now, to handle both old domain names, I figured I
| could use a class:
|
| DDerg.sri.com                           new domain name
| CDistc.sri.com itstd.sri.com            old domain names
|
| S1
| R$*<@$-.$=D>$*        $1<@$2.$D>$3      change domain name
| R$*<@$=D>$*           $1<@$D>$2         change domain name
|
| and likewise for S2.
|
| But this doesn't work; the matches against the class fail.  Reading the
| sendmail manual, it mentions something about "token" being the unit of
| a class.  I'm assuming the match is failing because "istc.sri.com" and
| "itstd.sri.com" are three tokens each rather than one.
|
| Is this right?  If so, is there a way to do what I want with classes?
|

Unless you've done a typo' then you've defined a macro (with the D) and a
class (with the C) both the macro and the class have the same name (D). I'd
write something like the below instead.

#
# Define Macro N (New-domain-name)
# and Class O (Old-domain-names)

#
DNerg.sri.com                               new domain name
COistc.sri.com itstd.sri.com                old domain names

S1
R$*<@$-.$=O>$*       $1<@$2.$O>$3           change domain name
R$*<@$=O>$*          $1<@$O>$2              change domain name

Of course I'd also have the old domains defined in a file and then use the
F command instead of C thus:

FO/usr/lib/domains.old                      old domain names

domains.old would contain..

istc.sri.com
itstd.sri.com

Then I'd be able to update the list of old domains without having to restart
and reconfigure sendmail (just in case I moved yet again).

    Mike Shaw.

/* The opinions expressed in this notice are my own and not those of Prime
   Computer Inc. */

-----------------------------

From: Neil Rickert <rickert at mp.cs.niu.edu>
Subject: Re: sendmail config file question
Date: 15 Aug 90 22:41:30 GMT
To:       unix-wizards at sem.brl.mil

In article <16300003 at WL9.Prime.COM> MSHAW at WL9.Prime.COM writes:
>
>I'm not a sendmail guru yet but here's my help anyway.
>
>Unless you've done a typo' then you've defined a macro (with the D) and a
>class (with the C) both the macro and the class have the same name (D). I'd
>write something like the below instead.

 There is nothing wrong with a macro and a class having the same name.  If
they are related it may even be a good idea.

>
>Of course I'd also have the old domains defined in a file and then use the
>F command instead of C thus:
>
>FO/usr/lib/domains.old                      old domain names
>
>domains.old would contain..
>
>istc.sri.com
>itstd.sri.com
>
>Then I'd be able to update the list of old domains without having to restart
>and reconfigure sendmail (just in case I moved yet again).
>

 Wrong!  You wouldn't have to change sendmail.cf.  But you would still need
to rebuild the freeze file (if used) with sendmail -bz, and you would still
need to kill and restart the daemon.

-- 
=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=
  Neil W. Rickert, Computer Sci Dept, Northern Illinois U., DeKalb IL 60115
  rickert at cs.niu.edu                                        +1-815-753-6940
=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=

-----------------------------

From: Thomas Truscott <trt at rti.rti.org>
Subject: Re: Is HDB locking safe?
Date: 15 Aug 90 19:46:12 GMT
To:       unix-wizards at sem.brl.mil

> ... HDB assumes that if the pid recorded
> in the lock file no longer corresponds to an active process, the lock file is
> defunct and can safely be removed.  I can't for the life of me figure out a
> safe way of doing this.

A crucial detail in recovering from a breakdown in the lock protocol
is avoiding a race between two or more processes that are simultaneously
attempting recovery.  Usually a strategic pause is all that is needed,
and as you can see in the HDB code below there is just such a pause.

> static int
> checklock(lockfile)
> char *lockfile;
> {
> 	...
> 	if ((lfd = open(lockfile, 0)) < 0)
> 		return(0);
> 	...
> 	if ((kill(lckpid, 0) == -1) && (errno == ESRCH)) {
> 		/*
> 		 * If the kill was unsuccessful due to an ESRCH error,
> 		 * that means the process is no longer active and the
> 		 * lock file can be safely removed.
> 		 */
> 		unlink(lockfile);
> 		sleep(5);		/* avoid a possible race */
> 		return(1);
> 	}
> 
> In this code there is no guarantee that lfd and lockfile correspond to the
> same file at the time of the unlink.

But there *is* a guarantee -- the "sleep(5);"!!
[I changed the sleep() line to match the one in 4.3 BSD uucp "ulockf.c"]

Consider a process "X" that discovers that the locking
process has terminated.  X unlinks the lockfile,
but then it *pauses* before it attempts to grab the lock for itself
(done by code not shown above).

Now consider scenario #1 for another process "Y":
At nearly the same instant Y discovers
the dead lock, so it also unlinks the lockfile
(of course only one unlink can succeed) and it *also pauses*.
Whenever X and/or Y resume there is no lock present,
so attempts to grab it proceed in the usual way (code not shown above).

Now consider scenario #2 for Y:
Just after X has unlinked the lockfile, Y calls checklock()
and discovers no lock is present.  No problem, it just
attempts to grab the lock in the usual way (code not shown above).
When X awakes from its slumber it will discover that Y has
already grabbed the lock, so X will just have to wait.

The HDB code is nice, but does have flaws:
(a) A "sleep(1);" is not enough to avoid a race on a very busy system.
(b) Lock recovery is obscure, so the sleep() call should be commented.
(c) Protocol breakdown is a bad thing, and should be reported:
	logent(lockfile, "DEAD LOCK");
The 4.3 BSD ulockf.c routine has all of these nice features.

	Tom Truscott

-----------------------------

From: Claude Goutier <goutier at iro.umontreal.ca>
Subject: Re: Is HDB locking safe?
Date: 16 Aug 90 09:17:30 GMT
Sender: news at iro.umontreal.ca
To:       unix-wizards at sem.brl.mil

In article <4024 at rtifs1.UUCP> trt at rti.rti.org (Thomas Truscott) writes:
>
>A crucial detail in recovering from a breakdown in the lock protocol
>is avoiding a race between two or more processes that are simultaneously
>attempting recovery.  Usually a strategic pause is all that is needed,
>and as you can see in the HDB code below there is just such a pause.
>
> ...
>
>The HDB code is nice, but does have flaws:
>(a) A "sleep(1);" is not enough to avoid a race on a very busy system.
>(b) Lock recovery is obscure, so the sleep() call should be commented.
>(c) Protocol breakdown is a bad thing, and should be reported:
>	logent(lockfile, "DEAD LOCK");
>The 4.3 BSD ulockf.c routine has all of these nice features.
>
>	Tom Truscott

If a sleep(1) is not long enough, why does a sleep(5) is?

If something is not prohibited to happen by construction (read solid
and serious interlock), whatever small the probability of it to happen,
it WILL happen!

One should never try to be smarter than a race condition. The only way
is to use true and solid interlocks (which should be provided in the
kernel and with the cooperation of the hardware). Have you ever programmed
on a machine with a fast CPU and ten peripheral processors all accessing
the same memory at the same time ?
--
 Claude Goutier             Services informatiques, Universite de Montreal
                            C.P. 6128, Succ "A",         Montreal (Quebec)
 goutier at jsp.umontreal.ca   Canada      H3C 3J7

-----------------------------

From: Roar Steen <roar at hpserv1.uit.no>
Subject: Broadcast UDP packets
Date: 15 Aug 90 19:56:59 GMT
Sender: USENET News System <news at hod.uit.no>
To:       unix-wizards at sem.brl.mil

Is there anybody out there who has some piece of code that 
demonstrates broadcast of UDP-packets. My system is a HP9000/375
workstation running HP-UX 7.0. 


--
//// Roar Steen                  // N-9001 TROMSOE, NORWAY              /
/// Computer Science Department // Phone : + 47 83 44051               //
// University of Tromsoe       // Telefax: + 47 83 44580              ///
/ NORWAY                      // Email: roar at sfd.uit.no              ////

-----------------------------

From: 8592x2 <jeff at astph.uucp>
Subject: shmat() system call?
Keywords: shmat()  systemV
Date: 15 Aug 90 20:11:02 GMT
To:       unix-wizards at sem.brl.mil


Question concerning the shared memory attach call:

I am writing a shared memory allocation manager for a multi-user
database. This manager will allow several processes to be attached
to the same memory segment at the same time. The first process to
attach to the shared memory segment will be returned a memory address
that points to the shared memory block. 

I need to know if additional attaches by other processes will be
guaranteed to return the same address as that the first process
was returned. I am aware that you can request a particular address,
but why bother communicating that information between the processes
if the same address is returned anyway? I would appreciate any
answers or direction to documentation.

Thanks		jeff martin
		astph!jeff at psuvax1
		philadelphia phillies

-----------------------------

From: Warren Tucker <wht at n4hgf.mt-park.ga.us>
Subject: Re: shmat() system call?
Keywords: shmat()  systemV
Date: 16 Aug 90 02:37:45 GMT
To:       unix-wizards at sem.brl.mil

In article <27 at astph.UUCP> jeff at astph.UUCP (8592x2) writes:
>
>Question concerning the shared memory attach call:
>
>I am writing a shared memory allocation manager for a multi-user
>database.
>I need to know if additional attaches by other processes will be
>guaranteed to return the same address as that the first process
>was returned.

To be sure, specify the attach address, regardless of what the FM says.
Make a small program that passes 0 for the address and see what it
returns.  Then, use that value hardcoded, possibly #defined for each
arcitecture you plan to run the program on.

I.E.,
/*---------------------- header file --------------------*/
#if defined(M_I286)
#define SHMPTR  char far *
#define SYSPTR  struct system_control *
#else
#define SHMPTR  char *
#define SYSPTR  struct system_control *
#endif

#if defined(M_SYS5)
#if defined(M_I386)
#define SHM_ATTACH_ADDR     ((SHMPTR)0x67000000L)   /* 386 */
#else
#define SHM_ATTACH_ADDR     ((SHMPTR)0x00670000L)   /* 286 */
#endif
#else /* not xenix */
#ifdef (pyr)
#define SHM_ATTACH_ADDR     ((SHMPTR)0xC0000000L)   /* PYRAMID */
#else
#define SHM_ATTACH_ADDR     ErrorInHeaderFile
#endif
#endif

/*---------------------- code file --------------------*/

    if((sys = shmat(*pshmid,SHM_ATTACH_ADDR,0)) !=
        (SHMPTR)SHM_ATTACH_ADDR)
    {
        /* attach error: either returned (SHMPTR)-1 or wrong address */
    }
 
 -----------------------------------------------------------------------
Warren Tucker, TuckerWare   gatech!n4hgf!wht or wht at n4hgf.Mt-Park.GA.US
"Tell the moon; don't tell the March Hare: He is here. Do look around."

-----------------------------

From: "BURNS,JIM" <gt0178a at prism.gatech.edu>
Subject: Re: shmat() system call?
Date: 16 Aug 90 05:41:44 GMT
To:       unix-wizards at sem.brl.mil

in article <27 at astph.UUCP>, jeff at astph.UUCP (8592x2) says:
> 
> 
> Question concerning the shared memory attach call:
> 
> I am writing a shared memory allocation manager for a multi-user
> database. This manager will allow several processes to be attached
> to the same memory segment at the same time. The first process to
> attach to the shared memory segment will be returned a memory address
> that points to the shared memory block. 
> 
> I need to know if additional attaches by other processes will be
> guaranteed to return the same address as that the first process
> was returned. I am aware that you can request a particular address,
> but why bother communicating that information between the processes
> if the same address is returned anyway? I would appreciate any
> answers or direction to documentation.

I don't see why not. The shmget(2) routine specifies the memory block
size. All the shmat(2) routine does is return a pointer to the beginning
of that block (by default). The same block is returned to different
processes if they use the same shmid returned by shmget(2). Adapted from
the HP 9000/800 HP-UX Real Time Programmers Manual:

On shmget(2):

"If your communication application consists of related processes, you
should call shmget(2) with the key parameter set to IPC_PRIVATE in the
following way:

   myshmid = shmget (IPC_PRIVATE, 4096, 0600);

"This call to shmget(2) returns a unique shared memory identifier (shmid),
which is saved in the variable myshmid, for the newly created shared
memory segment. The size of the segment is 4096 bytes and its access
permissions are read and write permission for the owner. This call to
shmget(2) should appear in your program sometime before the fork()
statement so that the child processes in your communication application
will inherit myshmid.

"If your communication application consists of unrelated processes, you
should call shmget(2) with the key parameter set to the return value of
the ftok() subroutine [or just use an ascii representation of a 4
character string that you know will be unique. - JB ] [...] As an example,
all unrelated processes in a communication application can call shmget(2)
in the following [altered - JB ] way:"

   myshmid = shmget (0x50485331, 4096, IPC_CREAT|600);

to use a key of "PHS1".

On shmat(2):

"Once a process has a valid shmid, it usually wants to attach, perhaps to
lock, to read and/or to write to, and then to detach the shared memory
segment. [...]

"A process must invoke the shmat() system call to attach a shared memory
segment to the data space of the process. The man page for shmop(2) lists
three parameters for shmat(): shmid, shmaddr, and shmflg.

"The first parameter, shmid, must be a valid shared memory identifier as
explained in the previous section.

"The second parameter, shmaddr, is the attach address of the shmid
parameter. Parameter shmaddr should be 0 in almost all cases. Only at
certain times and only in certain implementations of HP-UX can shmaddr be
other than 0. If a previous shmat() has not been called on the shmid; that
is, if the shared memory segment has not already been attached, then the
only correct value for shmaddr is 0. If, however, some process has already
called shmat() on the specified shmid, then the shmaddr can be 0 or some
other implementation - dependent value. [...] [As it turns out, non-zero
parameters aren't supported at all on the model 800 architechture - only
the 300. -JB ]

"The third parameter of shmat(), shmflg, is used only to further restrict
the owner's access permissions to the shared memory segment. [...]"

Hope this answers your question.
-- 
BURNS,JIM
Georgia Institute of Technology, Box 30178, Atlanta Georgia, 30332
uucp:	  ...!{decvax,hplabs,ncar,purdue,rutgers}!gatech!prism!gt0178a
Internet: gt0178a at prism.gatech.edu

-----------------------------

From: "BURNS,JIM" <gt0178a at prism.gatech.edu>
Subject: Re: shmat() system call?
Date: 16 Aug 90 06:32:18 GMT
To:       unix-wizards at sem.brl.mil

in article <187 at n4hgf.Mt-Park.GA.US>, wht at n4hgf.Mt-Park.GA.US (Warren Tucker) says:
< In article <27 at astph.UUCP> jeff at astph.UUCP (8592x2) writes:
< To be sure, specify the attach address, regardless of what the FM says.
< Make a small program that passes 0 for the address and see what it
< returns.  Then, use that value hardcoded, possibly #defined for each
< arcitecture you plan to run the program on.

What if yours is not the only application creating and deleting shared
memory segments? Are you saying you always get the same address?
~
~
~
~
~
~
~
~
~
"/usr/tmp/vn002876" 13 lines, 646 characters
still want to post it ? n
not posted
:more (34%):
-- 
BURNS,JIM
Georgia Institute of Technology, Box 30178, Atlanta Georgia, 30332
uucp:	  ...!{decvax,hplabs,ncar,purdue,rutgers}!gatech!prism!gt0178a
Internet: gt0178a at prism.gatech.edu

-----------------------------

From: Guy Harris <guy at auspex.auspex.com>
Subject: Re: Curses question
Keywords: key interpretation problems
Date: 15 Aug 90 20:33:18 GMT
To:       unix-wizards at sem.brl.mil

>(editor's note: This may be a duplicate transmision.  Sorry if you got it
>twice)

I only saw it once, but I did see the matching posting in
"comp.sys.sun"....

>The first one involves interpretation of input keys.  How can one tell the
>difference between the forward and backward tabs??  When I run my test   
>program, I get 0x09 for both.

As noted, the problem here is that in a "shelltool" window, there *is*
no difference.  What's more, different terminals may transmit different
things for the "backward tab", assuming they even have one; the BSD
"curses" doesn't have any way of recognizing the particular terminal's
notion of a "backward tab" sequence and translating it into some common
code for "backward tab".  The S5 "curses" might be able to do that.

>In addition, the code I'm getting in my test program for a return is
>different that the code which is returned in the real program (0x0a vs.
>0x0d) and yes, these two programs are being run on the same system.      

But probably *not* with the same modes.  0x0a is NL, and 0x0d is CR. 
The RETURN key on most terminals - including the "terminal" emulated by
a "shelltool" - sends CR; however, in some modes the UNIX tty driver
turns CR into NL.  Check out such "curses" functions as "nl()" and
"nonl()", which affect whether this mapping is in effect....

-----------------------------

From: William Kucharski <kucharsk at number6.solbourne.com>
Subject: Re: Another "why won't this work" program
Date: 16 Aug 90 00:26:38 GMT
Sender: news at solbourne.com
To:       unix-wizards at sem.brl.mil

In article <24183 at adm.BRL.MIL> BKEHOE at widener writes:
 >/*
 > * This is being run on a Sun SS1 under 4.0.3.
 > *  Theoretically, according to the Design & Implementation of 4.3BSD Unix,
 > * this should print out the ascii version of each process's current
 > * directory...instead, it chokes on u->u_cwd->cw_dir, which is in the
 > * u struct in sys/user.h .. any help, suggestions, etc would be greatly
 > * appreciated.
 >
 > */
 >
 >/*
 > * cc -o cwd cwd.c -lkvm
 > */
 >
 >#include <stdio.h>
 >#include <kvm.h>
 >#include <fcntl.h>
 >#include <ctype.h>
 >#include <pwd.h>
 >#include <sys/param.h>
 >#include <sys/time.h>
 >#include <sys/proc.h>
 >#include <sys/user.h>

 ...

 >	(void) printf("Name\t\tDir\n");
 >	kvm_setproc (kd);
 >	while ((proc = kvm_nextproc (kd)))
 >		if (proc->p_stat != SZOMB && proc->p_uid) {
 >			if (!(user = kvm_getu(kd, proc)))
 >				continue;
 >			(void) printf("%s\n", (getpwuid(proc->p_uid))->pw_name);
 >/* Curtains & Slow Music */
 >			(void) printf("%s\n", user->u_cwd->cw_dir);
 >/* It dies, but the user structure's fine (printing user->u_comm works); I
 >   stepped thru it with gdb & discovered that the pointer user->u_cwd is off in
 >   never-never-land; is it a valid entry in
 >the user structure? */
 >		}
 >}

That's because the user->u_cwd pointer is really a pointer into the kernel's
memory space, rather than user memory space.  You need to do something like
the following to read the contents of the kernel memory in question into user
space:

 ...

char dir[MAXPATHLEN];
char rootdir[MAXPATHLEN];
struct ucwd cwd;

if (kvm_read(kd, (unsigned long)userp->u_cwd, (char *)&cwd,
    sizeof(struct ucwd)) == sizeof(struct ucwd)) {

    if ((kvm_read(kd, (unsigned long)cwd.cw_dir, dir, MAXPATHLEN)
     == MAXPATHLEN) && (kvm_read(kd, (unsigned long)cwd.cw_root, rootdir,
     MAXPATHLEN) == MAXPATHLEN)) {
	if ((*rootdir) || (*dir))
	    printf("cwd: %s%s\n", rootdir, dir);
	else
	    printf("cwd: /\n");
    }
}

 ...

--
===============================================================================
| Internet:   kucharsk at Solbourne.COM	      |	William Kucharski             |
| uucp:	...!{boulder,sun,uunet}!stan!kucharsk |	Solbourne Computer, Inc.      |
=== The sentiments expressed above are MY opinions, NOT those of Solbourne. ===

-----------------------------

From: "jeffrey.n.jones" <jeffj at cbnewsm.att.com>
Subject: How to restrict commands in rsh?
Date: 15 Aug 90 21:37:00 GMT
To:       unix-wizards at sem.brl.mil


A co-worker and I were trying to figure out how to restrict the commands
a user can use in rsh. In the manual there is a mention of a directory
where you can put the commands that you want to restrict called 
/usr/rbin
How do you do this? Do you put all of the commands in a single file? What 
do you call this file? Thanks ahead of time for any help!

                     Jeff Jones

-- 
         Jeff Jones        | Prediction is very difficult, especially 
 UUCP   uunet!seeker!jeffj | about the future.
 Infolinc BBS 415-778-5929 |                   Niels Bohr

-----------------------------

From: Bertrand Meyer <bertrand at eiffel.uucp>
Subject: Vi fails on a Sun-4
Keywords: Illegal instruction
Date: 15 Aug 90 22:09:47 GMT
To:       unix-wizards at sem.brl.mil


Has anyone run into the following problem, which
is becoming an increasing nuisance for me?

Vi (on a Sun-4, running SunOS 4.0) fails
according to totally unpredictable patterns.

For example (vg is an alias that uses vi):

>   [Rome] bm 592 - vg instruction
>   Illegal instruction (core dumped)
>   [Rome] bm 593 - vi Grammar/instruction
>   Illegal instruction (core dumped)
>   [Rome] bm 594 - vi Grammar/instruction
>   Illegal instruction (core dumped)
>   [Rome] bm 595 - cd Grammar
>   [Rome] bm 596 - vi instruction
>   Illegal instruction (core dumped)

	I have experienced similar problems for a long
time, but it used to be only when calling vi with
several file arguments (I have many scripts which do
this, based on grep searching). Now, as the above shows,
it's occurring even with just one file!

Another example occurred as I was trying to send mail
(describing the problem!) and the ~v command of mail
failed with ``Fatal error in "usr/ucb/vi"''.

The problem does not occur identically in different
windows. Usually command windows fail less often than
shell windows. Yesterday, I experienced a situation
with two windows, where vi would work in window A
(a command window) except if the number of file arguments
was equal to 2, and would work in window B (a shell
window) for 1 or 2 arguments, but apparently for no
other number of arguments!

I would be grateful if anyone has any suggestion about
what is going on (other than ``switch to Emacs'').
A text editor seems a pretty basic tool to me, and
after all these years one might hope that vi would
work. I don't suspect Bill Joy reads this, however.

I would appreciate mail replies to bertrand at eiffel.com.
If I receive anything of general interest I will post a
summary.

Thanks in advance.

-- Bertrand Meyer
Interactive Software Engineering, Santa Barbara, CA.

bertrand at eiffel.com

-----------------------------

From: Mike McNally <m5 at lynx.uucp>
Subject: Directory compression
Keywords: 4.3BSD
Date: 15 Aug 90 23:03:16 GMT
To:       unix-wizards at sem.brl.mil

Does 4.3BSD (or anything else) dynamically compress directories when
entries are removed?  If so, how does the system deal with
consistency?  Like if I'm reading while something else is unlinking and
the directory is being compressed, how does the world go on living?
-- 
Mike McNally                                    Lynx Real-Time Systems
uucp: {voder,daver}!lynx!m5                     phone: 408 370 2233

            Where equal mind and contest equal, go.

-----------------------------


End of UNIX-WIZARDS Digest
**************************



More information about the Comp.unix.wizards mailing list