HDTenEightyP/NetNews huggingface dataset:
From: mju@mudos.ann-arbor.mi.us (Marc Unangst)
Subject: Re: Need help with System()
Date: Sun, 30 Aug 1992 15:35:27 GMT
Organization: The Programmer's Pit Stop, Ann Arbor MI
Keywords: Need help with System()

In article <1992Aug28.140705.501@polari> errant@polari.online.com writes:
>detected, but then it drops through and prints bad.  What gives??
>Is there something I could add to the code that would show me??
>I'm stumped!

Well, first off try reading the system(3) manpage to find out what the
system() call returns.  Hint: it isn't the same as the value of "$?"
after running a command in the Bourne shell.

Second, you would probably be better off staying away from doing ugly
things like this in your program.  Other people will grimace at you
and say bad things about your mother behind your back.  Instead, use
popen(3) to get the output from ps(1) and parse it yourself.  Much
simpler and easier, and less filling too.

-- 
Marc Unangst                | Real men don't make backups.  Real men never
mju@mudos.ann-arbor.mi.us   | accidentally delete files that they're going
                            | to need later.
From: mike@pacsoft.com (Mike Stefanik)
Newsgroups: comp.unix.programmer
Subject: Re: Sco Xenix or Unix - which to program for?
Date: 27 Aug 92 09:12:26 GMT
Organization: Pacific Software Group, Riverside, Ca.

In article, peter@ferranti.com (peter da silva) writes:
>[...] That is, a SCO Xenix program will run on SCO UNIX, but not vice-versa.

Hold on a second here -- XENIX can load and run COFF executables.  Naturally
it will choke if the program does intrinsically non-portable stuff (such as
nlist() or mucking about with luid's... but that's the case regardless if
you are running a XENIX executable under UNIX or vice versa.)

-- 
Mike Stefanik  mike@pacsoft.com  ...!uunet!pacsoft!mike
Pacific Software Group, Riverside, CA
Xref: sparky comp.unix.programmer:4504 comp.lang.c:13038 comp.arch:9109
From: frankred@cogsci.ed.ac.uk (Martin Redington)
Newsgroups: comp.unix.programmer,comp.lang.c,comp.arch
Subject: Re: What would you like in a debugger?
Date: 30 Aug 92 23:44:59 GMT
Organization: Centre for Cognitive Science, Edinburgh, UK

In article <1992Aug24.190039.1906@nstn.ns.ca> maceache@fox.nstn.ns.ca (Tim Maceachern) writes:
>I don't know if anyone has mentioned this, but I would like a source
>debugger to be smart enough to know what is code and what is (are)
>comments.  Then show the comments in a different colour than the
>code.  If you're using monochrome, sorry.

The quickC for windows source editor is even better than this
comments, strings, numbers etc. all appear in user-configurable
colours. While this is fine if you are using only this, it tends
to encourage bad habits, like extraneous comments, on the same 
line of code (hey, why have colour, if your not going to use it).

If you have to read your source later on a mono terminal,
things can get very confusing. The conclusion I drew was,
if you need colour to discern your comments, the code could do
with some rearrangement anyway. Of course if your a bit more
disciplined than me, this won't bother you.

                                         Martin.
From: markp@adsi.homecare.com (Mark Parr)
Newsgroups: comp.unix.programmer
Subject: Getting the IP address of a 'rlogin'ed user
Date: 28 Aug 92 15:01:12 GMT
Organization: Application Data Systems, Inc.

I'm looking for a function that when called will return the IP address the 
machine from which a user is 'rlogin'ed.

For example, if a 'who' shows the following:

     billp       tty5        Aug 28 07:55                          
     brucec      tty6        Aug 28 08:44                          
     jdoe        pts/0       Aug 28 09:53          (adsi)          
     bob         pts/1       Aug 28 09:53          (ibm)           
     smith       pts/2       Aug 28 09:53          (ibm)           

I would assume the function would work along the lines of

      function(user, tty)

Example:
     
      getip("smith", "pts/2") -> returns 89.0.0.1

where 89.0.0.1 is the IP address of ibm.

Does this function (or something similar) exists?

-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
 | |-------------|  Application Data Systems     |  Phone: (601) 393-2046  | |
 | |  Mark Parr  |  1930-B 1st Commercial Dr. N  |    Fax: (601) 393-6605  | |
 | |-------------|  Southaven, MS 38671          | markp@adsi.homecare.com | |
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
From: barmar@think.com (Barry Margolin)
Newsgroups: comp.unix.programmer
Subject: Re: Sending "datagrams" on a connected socket.
Date: 1 Sep 1992 19:07:29 GMT
Organization: Thinking Machines Corporation, Cambridge MA, USA
NNTP-Posting-Host: telecaster.think.com

In article <1992Sep1.061951.6750@csc.ti.com> fcw@telecom.ti.com writes:
>I can add a layer onto a stream or datagram socket, but it would be
>nice if some incantation of socket library calls can do it instead.
>Email or net help would be appreciated... Either suggestions how to do
>it or a knowledgeable statement that it ain't possible.

There's no built-in mechanism to delimit messages on a stream socket.  It's
trivial to add such a layer on top of it, though.  Just send a byte or two
containing the message length (depending on the max size of your messages)
followed by that much data.  If the length is two bytes, make sure you
define a canonical byte order (e.g. use htons() and ntohs() to
encode and decode the length).
-- 
Barry Margolin
System Manager, Thinking Machines Corp.

barmar@think.com          {uunet,harvard}!think!barmar
Newsgroups: comp.unix.programmer
From: upkar@wsu-eng.eng.wayne.edu (Upkar Singh Kohli)
Subject: two questions
Reply-To: upkar@eng.wayne.edu.UUCP (Upkar Singh Kohli)
Organization: Wayne State University, Detroit
Date: Fri, 4 Sep 1992 15:38:13 GMT


1. What is the best way to disable echo from within a C program?
   The purpose is read a password.

2. What is the best unique identifier for machines to use for
   software licensing? I have heard that even the "effective"
   ethernet address can be changed. I know the hostids can easily
   be changed on certain architectures like DEC and SGI.

Thanks!
Upkar

(if possible please email upkar@eng.wayne.edu... followup over
 news will be ok too, except I read it less)

Xref: sparky comp.unix.programmer:4459 comp.unix.xenix.sco:2748
From: michi@ptcburp.ptcbu.oz.au (Michael Henning)
Newsgroups: comp.unix.programmer,comp.unix.xenix.sco
Subject: Re: Calling longjmp() from signal handler: portable?
Date: 27 Aug 92 00:10:05 GMT
Organization: Pyramid Technology Corporation

chip@tct.com (Chip Salzenberg) writes:

>In working on Smail 3, I've found that I need to interrupt a blocking
>system call (a kernel locking primitive, to be precise).  Ron Karr
>seems to think that calling longjmp() from a signal handler will work
>with all known versions of UNIX, not just with BSD as I assumed.

>Is Ron right that longjmp() always works from signal handlers?  Or am
>I correct that, for example, SCO Xenix sets up a separate stack frame
>for signal handlers, so longjmp() won't work correctly?

From the setcontext(3C) man page on our V.4 system (Pyramid DC/OSx):

When a signal handler is executed, the current user context is saved
and a new context is created by the kernel.  If the process leaves the
signal handler via longjmp(3C) the original context will not be
restored, and future calls to getcontext will not be reliable.  Signal
handlers should use siglongjmp(3C) or setcontext instead.


The man page for sigsetjmp(3C) says:

sigsetjmp saves the calling process's registers and stack environment
[see sigaltstack(2)] in env (whose type, sigjmp_buf, is defined in the
<setjmp.h> header file) for later use by siglongjmp. If savemask is
non-zero, the calling process's signal mask [see sigprocmask(2)] and
scheduling parameters [see priocntl(2)] are also saved. sigsetjmp
returns the value 0.


So, the answer is that if you haven't done anything strange with setcontext
or sigaltstack, setjmp/longjmp should be OK, otherwise use sigsetjmp/siglongjmp.

								Michi.
-- 
      -m------- Michael Henning                 +61 75 950255
    ---mmm----- Pyramid Technology              +61 75 722475 FAX
  -----mmmmm--- Research Park, Bond University  michi@ptcburp.ptcbu.oz.au
-------mmmmmmm- Gold Coast, Q 4229, AUSTRALIA   uunet!munnari!ptcburp.oz!michi
Newsgroups: comp.unix.programmer
From: ccechk@nuscc.nus.sg (Heng Kek)
Subject: sccs: how to include rev. history?
Organization: National University of Singapore
Date: Wed, 26 Aug 1992 03:19:57 GMT

Greetings,

How can I use sccs to include the history of revisions in my source
code?  For e.g. I'd like to see something like the following lines
in my source code, following a 'delta' and 'get':

#! /usr/local/bin/perl
# $Id: jj.logger,v 1.3 92/08/25 16:00:34 John Thomas:jt $
#
# $Log:	jj.logger,v $
# Revision 1.3  92/08/25  16:00:34  jt
# Fixed divide by zero error if no mail either delivered or sent.
# 
# Revision 1.2  92/08/05  14:03:14  jt
# Replaced '=' with '-' in output report
# 
# Revision 1.1  92/07/22  16:36:54  jt
# Logfile processor 
#

The above was extracted from some public domain source and I realise
that it probably wasn't created using sccs.

I've tried to look for the solution by reading the man pages for
the sccs commands but to no avail.  Does a solution exist for sccs?

Another question:  How do I use the various sccs modules (rmdel,
unget, delta, get etc) to effect what is achieved by 'sccs fix'?

Thanks in advance for any responses.

Heng Kek
From: sweh@spuddy.uucp (Stephen Harris)
Newsgroups: comp.unix.programmer
Subject: C-Kermit scripts
Date: 26 Aug 92 11:05:01 GMT
Organization: Spuddy's Public Usenet Domain

Many apologies if this is the wrong group, but the only "kermit" groupt I
could find was comp.protocols.kermit - and this is not a protocol question.
*Gentle* redirection would be appreciated if I am wrong.

I am writing a script in C-kermit 5A under SunOS 4.1 and have the following
problem:
After sending a sequence of characters to the remote end it will either
reply
Accepted ##########
or
Rejected ##########

I can test for accepted or rejected with "input 5 accepted" "if success" but
what I also need to know are the ########### which will be different every
time.
How can I get these numbers into a variable?
I have tried obvious things like
input 5 success
clear
input 0 \10
echo \v(input)

but it doesn't work.

Reading input from the session into a variable must be pretty common....

Any ideas?  help please!
Thanks.
-- 
                               Stephen Harris
               sweh@spuddy.uucp    ...!uknet!axion!spuddy!sweh

 * Meeeeow ! Call Spud the Cat on > +44 203 638780 < for free Usenet access *
From: ilan343@violet.berkeley.edu (Geraldo Veiga)
Newsgroups: comp.unix.programmer
Subject: scandir for SYSVR3.2
Date: 29 Aug 1992 17:27:02 GMT
Organization: University of California, Berkeley
Distribution: usa
NNTP-Posting-Host: violet.berkeley.edu
Originator: ilan343@violet.berkeley.edu


Where can I find the cource for a scandir implementation known to work
under SysV3.2 (ISC 2.2 in my case, but I am assuming this function is
not present in SysV < 4.0).

I tried the one from BSD and it would need some hacks to make it work.

Thanks in advance.
From: dtb@otto.bf.rmit.oz.au (David Bath)
Newsgroups: comp.unix.programmer,comp.sys.hp.comp.sys.dec
Subject: Re: Best malloc(3) replacement for huge sys w/many small objects?
Date: 27 Aug 92 00:40:30 GMT
Organization: RMIT Computer Centre, Melbourne Australia.

markmc@sierra.com (Mark McWiggins) writes:
...

>     Currently, the allocator is unsuitable for direct use in a large virtual
>     environment where many small blocks are kept, since it keeps all allo-
>     cated and freed blocks on a circular list.  Just before more memory is
>     allocated, all allocated and freed blocks are referenced.

Use of malloc(3) rather than malloc(2) does this I think by preallocating
in decent hunks.  Use cc ...... -lmalloc to get the malloc(3).

========================================================================
David T. Bath
email: 	dtb@otto.bf.rmit.oz.au
Work: 	Global Technology Corporation, Carlton, Vic, OZ  (03) 3477511
=======================================================================
Newsgroups: comp.unix.programmer,comp.unix.wizards
From: am815@cleveland.Freenet.Edu (Joel Peter Anderson)
Subject: STREAMS M_ERROR Message problem
Reply-To: am815@cleveland.Freenet.Edu (Joel Peter Anderson)
Organization: Case Western Reserve University, Cleveland, OH (USA)
Date: Wed, 26 Aug 92 13:07:39 GMT


I am running UHC's System V.4 Unix on a 486.

I have a serial communications card which has loaded on it a
protocol stack.  A user application interacts with the protocol
stack through a device driver whose head is a STREAM.  To get and
put data to the driver, a user application would use read() and
write().

Currently, if the protocol stack encounters an error on a user
application write, it sends back to the driver a negative status
code.  The driver then converts this into a M_ERROR message which
is put on the read queue using putq.  To make turn the message into
an M_ERROR message the following is done:

make_error_msg(mblk_t *mp, int status_code) {
    
    mp->b_datap->db_type = M_ERROR;
    mp->b_rptr = mp->b_datap->db_base;
    *mp->b_rptr = status_code;
    mp->b_wptr = mp->b_rptr + sizeof(char);
    ....
} 

The result is the next read or write returns with a -1 and errno is
set to 256 - status_code.  The PROBLEM is that the only way to
clear the error condition is to close the device.  Typically, the
error does not warrent a close.

The man pages on STREAMS error message types indicate that there
are two forms of the M_ERROR message - one byte and two byte.  The
one byte form is suppose to lock out all system calls to the device
except close and poll.  However, the two byte form is set up so
that "the first byte [of the status code] is the read error and the
second byte is the write error.  This allows for modules to set a
different error on the read-side and write-side.  This allows a
module to set an error on just one side of the STREAM."  When I
change the code to construct a two-byte M_ERROR msg...

make_error_msg(mblk_t *mp,char status_code) {
    
    mp->b_datap->db_type = M_ERROR;
    mp->b_rptr = mp->b_datap->db_base;
    *mp->b_rptr = status_code;
    *(mp->b_rptr + 1) = NOERROR;
    mp->b_wptr = mp->b_rptr + ( 2 * sizeof(char));
}

the result is the same as with the one byte M_ERROR message.  Both
read and writes return a -1 with errno = status_code.  What am I
doing wrong?

-------------------------------------------------------------------------
"We know only the strong will survive, But the meek will inherit.
 So if you've got a coat of arms, oh friend, I suggest we wear it."
                                        John Mellencamp.
-------------------------------------------------------------------------
  joela@Apertus.COM  s/w engneer |Freenet: am815@cleveland.freenet.edu
    Joel Peter Anderson          |PNET: jpa@pnet51.orbit.mn.org
    Apertus Technologies         |GEnie:J.ANDERSON71
-------------------------------------------------------------------------
-- 
-------------------------------------------------------------------- 
<Joel Peter Anderson>               |     
Freenet: am815@cleveland.freenet.edu|    Signature under 
 GEnie:J.ANDERSON71                 |      construction.
From: hawkeye@glia.biostr.washington.edu (Ken Keys - TF Dude)
Newsgroups: comp.unix.programmer
Subject: Re: Unix Programming Question
Keywords: Unix
Date: 31 Aug 92 22:30:31 GMT
Article-I.D.: glia.hawkeye.715300231
Organization: University of Washington

In <1571@dcsc.dla.mil> cop3409@dcsc.dla.mil (Joseph NMN Delmedico) writes:

>I have a program that employs the following command :

>      system("ls -l /path1/??/n???????.?? > /path2/upload.lst")

>to give me a list of upload file from different directories for processing.
>If there are no files present of this type, nothing needs to be done.
>However when the program runs and there are no files present I get an
>error message from the superuser saying the program was run and no files
>were found.  Since program must be run many times throughout the day these
>messages pile up in my mailbox and have to be deleted.

>  So my question is, is there any means of turning off this feature so I
>don't have to waste time deleting these messages?

The error messages are printed on standard error, but you only redirected
standard output.  Assuming your system() uses /bin/sh,

      system("ls -l /path1/??/n???????.?? > /path2/upload.lst 2>&1")

will do what you want.
-- 
--
Ken Keys, aka Hawkeye
Master of the Fugue
kkeys@ucsd.edu or hawkeye@ucsd.edu
From: aj639@cleveland.Freenet.Edu (Michael Cox)
Newsgroups: comp.unix.programmer
Subject: writing a daemon
Date: 3 Sep 1992 19:20:36 GMT
Organization: Case Western Reserve University, Cleveland, OH (USA)
Reply-To: aj639@cleveland.Freenet.Edu (Michael Cox)
NNTP-Posting-Host: slc5.ins.cwru.edu


Anyone have good books on how to write a friendly daemon in C on aSPARC?

Mike
-- 
Okay, look for AmoNER DIsk #4 on:
ux1.cso.uiuc.edu (128.174.5.59) in /amiga/amoner
nic.funet.fi (128.214.6.100) in /pub/amiga/programming/amos
From: fcw@telecom.ti.com (Fred Wedemeier)
Subject: Sending "datagrams" on a connected socket.
Reply-To: fcw@telecom.ti.com
Organization: TI Telecom Systems, Dallas
Date: Tue, 1 Sep 1992 06:19:51 GMT

I've RTFM'd sections (2) and (4) of the UNIX manual, hammered out some
test code, and still can't figure out how to do the following:

I need two processes to talk to each other in a "reliable,
flow-controlled, in-order, two-way" manner, quoting tcp(4). These
processes need to exchange discrete messages rather than boundary-less
streams of bytes.

I've tried a number of things with SOCK_STREAMs and send()/recv(), all
of which which concatenate messages if the receiving process isn't
waiting when each message arrives. For example, if I send() a message
"hello" followed by a message "goodbye" and then recv() at the other
end, what I get is "hellogoodbye" rather than a "hello" and a
"goodbye."

It appears that features of both SOCK_STREAMs and SOCK_DGRAMs are
needed. Or more likely a SOCK_SEQPACKET, which according to socket(2)
is "presently not implemented for any protocol family."

I can add a layer onto a stream or datagram socket, but it would be
nice if some incantation of socket library calls can do it instead.
Email or net help would be appreciated... Either suggestions how to do
it or a knowledgeable statement that it ain't possible.

thx.
---
Fred Wedemeier    pho: 214-997-3213     fax: 214-997-3639
                timsg: fcw             inet: fcw@pioneer.telecom.ti.com

Newsgroups: comp.unix.programmer
From: grabenst@umbc4.umbc.edu (Mr. Michael Grabenstein; ACS (GUEST))
Subject: Communicating with a port.
Organization: Univ. of MD, Baltimore County
Date: Fri, 4 Sep 1992 16:49:10 GMT

	I am trying to write a program that talks to a port on
my sun (SunOS v4.1.1). I just can't seem to do it. BTW on the
port is a modem. Could some one point me in the right direction?

	Also is there a GOOD book on how to program UNIX to open
serial ports?

	Thanks!

Later,
	Mike
	ZMEG@AACC.bitnet
	or grabenst@umbc3.umbc.edu
}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{
The universe -- The ultimate fractal. 
	--Personal theroy
Newsgroups: comp.unix.programmer,comp.unix.wizards
From: bas@phys.uva.nl (Bas de Bakker)
Subject: Re: detecting process death from unrelated process
Organization: Institute for Theoretical Physics, Amsterdam, the Netherlands
Date: Thu, 27 Aug 1992 13:25:02 GMT

>>>>> On Tue, 25 Aug 1992 22:50:21 GMT, gerald@atlastele.com (Gerald Aden) said:

ga> Is there a way for process A to detect that process B has exited where
ga> process A has the pid of process B but is not the parent of process B?

You could try using kill() with a zero signal number, and check its
return value.

Bas de Bakker.
Newsgroups: comp.unix.programmer
From: kleung@esk.compserv.utas.edu.au (Kam  Leung)
Subject: implementation of semaphores in unix 
Organization: University of Tasmania at Launceston
Date: Thu, 27 Aug 92 11:50:17 GMT


Dear guys,
      I have a difficulty in enforcing the mutual exclusion between
5 philosophers because I couldn't effectively change the global 
variables such as the major semaphore (me), and the private semaphore
(s[i]).  Could anybody suggest an answer for me or comment on my logic
below.  Your kind attention is much appreciated.  Thanks...

Regards
Keith LEUNG
kleung@esk.compserv.utas.edu.au

#include <stdio.h>
#include <sys/types.h>
#define N              6
int  s[N], me;
enum status {nthinking,vhungry,neating} ;
enum status p[N];
main()
{
  int i, ;
  void  PHILOSOPHER(), 
        think(), eat(), hungry();

  me = 1;    /* initial open state of main semaphore */

  for (i=1;i<N;i++) /*initialise 1-5 philosophers to thinking*/
      { s[i] = 0; p[i] = nthinking;}  /* private semaphore s[i]=0,close*/

  for (i=1; i<N; i++){
	if (fork() == 0) PHILOSOPHER(i);
  }
        ..
        ..
  kill(0,9);
}
void PHILOSOPHER(i)
int i;
{
		think(i);
      -----------waitfor(me); 
      !     /* see whether the sem. is open(me=1) or close(me=0)
      !        if me=1, pass thru, and set the me back to 0   */ 
      !		hungry(i);
      !         philosopher i = hungry
      !         printf("\nphil %d has gone into c.s.",i);
      !         check if the lefthand and righthand philosopher 'not eating'  
      !         if it is so,  set itself = eating, release private sem.
      !         of itself : signalto(p[i]) -- supposed to set p[i] = 1
      !         but didn't...... 
      ---------	signalto(me);
		waitfor(s[i]);
		eat(i);
      --------	waitfor(me);
      !           ..
      !           ..
      !         activate the neigbouring philosophers (ready to eat)
      !           ..
      !           .. 
      ----------signalto(me);
                printf("phil %d has finished eating and asking other to eat" );

waitfor(i)
int i;
{
	if (i >= 1)   {  i--; }
	else
	  {  waitfor(i); } 
	return i;
}
signalto(i)
int i;
	{return i++;}

Newsgroups: comp.unix.programmer,comp.unix.internals,comp.unix.questions
From: mstehr@lascar.puc.cl (Martin Stehr)
Subject: Monitoring ethernet segment using PROMISC mode
Organization: Pontificia Universidad Catolica de Chile
Date: Tue, 25 Aug 1992 21:05:00 GMT


Hi,

	I' am currently working on my thesis constructing some kind of
active network monitoring system. Actually the system is collecting 
information from multiple hosts, obtaining about each host kernel info
like job queues, disk I/O, context switches, device interrupts, page 
faults, swapping, etc. Also it can get info about for exampe TCP bytes 
and packets I/O on that host. The active part of the system is going to
be used experimentally in order to create some loads on some hosts or
between two of them, laying on the same or different ethernet segments.
The whole is going to be used remotely by other people for tuning or 
testing different configurations for hosts and connections.

	Now I'm searching for some method to obtain general info about
some ethernet segment, so as the *total* number of packets and bytes sent on 
the segment (not only to the specific host where the monitor daemon is
installed), considering all packets at the IP layer.

	I wonder if this could be possible opening a raw socket, setting
the corresponding ethernet device on *promisc* mode and using recvfrom()
to get all the incoming packets.

	I'll appreciate any info about:

1) if that's really possible
2) how does it affect system performance (more device interrupts ?)
3) some simple (?) method of doing the task by some kind of daemon
   installed on the system (I don't want to rebuild part of the kernel !)

	Our system runs a 4.3BSD Unix.

Any help would be appreciated !

Greetings from Chile - Southamerica :)


mstehr@lascar.puc.cl

Newsgroups: comp.unix.programmer