HDTenEightyP/NetNews huggingface dataset:
From: dwight@hyphen.com (Dwight Ernest)
Subject: Re: Programs that fork() don't redirect output in desired way?
Organization: Hyphen, Inc., Wilmington, MA 01887 USA / +1 508 988-0880
Date: Mon, 21 Dec 1992 16:37:18 GMT

kbahey@ncrsaud.SaudiArabia.NCR.COM (Khalid Bahey-elDin) writes:

>The following is the same on AT&T UNIX V.3 and V.4.

>The scenario is that a program (a background communication interface) is
>invoked, and it fork()s 2 children. The parent monitors both children, and
>one child deals with inbound traffic, the other with outbound traffic.

>In this program, we have a lot of printf()s used for debugging and tracing, and
>are only active when we compile with a -DDEBUG compiler flag.

>We let the program run in the background, and redirect stdout, and stderr to a
>holding debug file, via the shell command:

>prog > debug.out 2>&1 

>Because "prog" breaks itself into three running processes, we have three
>different processes redirecting their output to the debug file.

>The problem is that the file does not contain things in chronological order.
>What happens is that it will contain output from the parent, then output from
>child1, then output from child2, all interspersed.

>I assume this is because of system buffering for printf()s.

>Of course I can rewrite the printf()s so as they would write to a special log
>file, but this would be a considerable effort, plus it will deprive us of the
>flexibility of displaying output directly to the terminal when we want to.

>What is an easy way to get the output of all three processes correctly in
>correct chronological order?

There's no clean way to completely avoid race conditions like you
describe without a coding effort, which you say you're trying to
avoid.

A better algorithm, though, if you wanted to recode, would be to have
the parent open the debug file instead of using redirection, and then
use some sort of locking mechanism to allow one instance of the program
to write to the output file at a time.

A cheap and easy way to at least mitigate the effect would be to call
fflush() after each printf.  RTFM.  It won't entirely do away with the
problem, but it should help.
-- 
--Dwight A. Ernest   R&D Manager (USA)     I speak only for myself.
  Hyphen, Inc./181 Ballardvale St./Wilmington, MA 01887/+1 508 988 0880 x125
  dwight@hyphen.com
From: Kari.Hurtta@Helsinki.FI (Kari E. Hurtta)
Newsgroups: comp.unix.programmer
Subject: Re: Pipes/Sockets/Pty's/Communications
Date: 30 Dec 92 19:02:17 GMT
Organization: Department of Computer Science, University of Helsinki, Finland

In article <1992Dec30.160512.10958@linus.mitre.org> bdickens@elara.mitre.org (Brian Dickens) wrote:
> I want to be able to send commands to the program and get answers back,
> but using standard piping techniques have been unable to help me so far,
> since the output of the program seems to be *buffered*!!!

C'c IO-library line bufferes output, if output goes to terminal,
otherwise it block bufferes output. This is reason why, you need pty.

--
- K E H                                      /  Eldmd on monimutkaista
  Kari.Hurtta@Helsinki.FI
Newsgroups: comp.unix.programmer
From: u7911093@cc.nctu.edu.tw (Erik Wang)
Subject: How to print 2pages on 1paper?
Organization: National Chiao Tung University
X-Newsreader: TIN [version 1.1 PL6]
Date: Thu, 31 Dec 1992 18:31:18 GMT

Hi,all,

	Ask two problem about the Laser printer + PostScript.....
	Who can tell me which program can print two pages text data on
one side of one paper?  as following:

+------------------+------------------+
| xxx  xxx xx      |     xxx   xxx  x |
|  xxxx  xxx  xx   | xxxxx  xx   xxx  |
:   :    :         :      :    :      :
:   :    :         :      :    :      :
| xxx  xxx xx      |     xxx   xxx  x |
|  xxxx  xxx  xx   | xxxxx  xx   xxx  |
| 1                |                2 |
+------------------+------------------+

	and by the way, Is there any program which can print text data on
two side of one paper?


		Thankx for any help.

		Regard,
		Erik


--
	Erik Wang :)
From: rmascaro@uniwa.uwa.edu.au (Robert Mascaro)
Newsgroups: comp.unix.programmer
Subject: login/lpr src
Date: 22 Dec 1992 13:39:44 +0800
Organization: The University of Western Australia
NNTP-Posting-Host: uniwa.uwa.edu.au
X-Newsreader: Tin 1.1 PL5

Could someone please mail me login and lpr source to enable us to
program our MVS system for security and printing. We would then be able
to look at how the protocols work and provide an MVS solution.
Many thanks to whoever could oblige.
Rob.
ps. We have unix systems networked to MVS systems via TCP/IP protocols.
Newsgroups: comp.unix.programmer
From: bill@bilver.uucp (Bill Vermillion)
Subject: Re: Business Opportunity
Organization: W. J. Vermillion - Winter Park, FL
Distribution: usa
Date: Thu, 31 Dec 1992 17:14:12 GMT

In article <1992Dec29.173625.28102@netcom.com> bilan@netcom.com (Steve Bilan) writes:
>mlake@irscscm.UUCP (Marshall Lake) writes:
>>
>>We at TEAM Software are considering putting together a catalogue of
>>computer software for the end user.
>> :
>>We expect the programmer to make a royalty of 10% to 15% of
>>our gross.

>No money up front and only 15% royalty????  What a rip-off!

And the 15% of a $5 program is only 75 cents.   Now if you have
a top-of-the-line program, that sells for $15, you can make
$2.25  WHOOPEE :-)

So to make a decent amount, they'd have to sell well in excess
of 20,000 copies of your program.   Perhaps do-able in a DOS
oriented environment but surely not in this area.

-- 
Bill Vermillion - bill@bilver.oau.org  bill@bilver.uucp
                - ..!{peora|tous|tarpit}!bilver!bill
From: subbarao@fc.hp.com (Kartik Subbarao)
Newsgroups: comp.unix.programmer
Subject: Re: Info Needed on programming w/sockets
Date: 27 Dec 92 18:32:51 GMT
Reply-To: subbarao@fc.hp.com
Organization: putchar('I'); for (i = 0; i < 3; i++) putchar('E');
Originator: news@nimaster

In article <78825@hydra.gatech.EDU> gt5870c@prism.gatech.EDU (Noah White) writes:
>
>    I am starting a program which will use sockets. I have never used them
>before but have read and understood the man pages for socket, bind, 
>listen etc. However I would like some more indepth information and 
>perhaps programming examples for sockets (Internet domain, SOCK_STREM
>style). Could anyone point me in the right direction? Thanks!

The best thing to do here is NOT read the manual pages. That is, don't read
them until you have learned about them. An excellent book to learn about
sockets and the like is UNIX Network programming by W. Richard Stevens. He
also has another book out called Advanced Programming in the UNIX
Environment. Other good books include the section on socket implementation
in the demon book, as well as Comer's Internetworking with TCP/IP (Volume 3
has extensive coverage of sockets).

Sun's Answerbook also has a chapter or two on this stuff.
	
	-Kartik
Newsgroups: comp.unix.programmer
From: mcobb@scott.skidmore.edu (mary cobb)
Subject: Re: FAQ request
Organization: Skidmore College, Saratoga Springs NY
Date: Fri, 1 Jan 1993 16:31:18 GMT

There should be a FAQ on getting a FAQ.  I need one too.

Eric
From: bhoughto@sedona.intel.com (Blair P. Houghton)
Newsgroups: comp.unix.programmer
Subject: Re: How to print 2pages on 1paper?
Date: 31 Dec 1992 20:00:45 GMT
Organization: Intel Corp., Chandler, Arizona
NNTP-Posting-Host: stealth.intel.com

In article <1992Dec31.183118.29509@debbie.cc.nctu.edu.tw> u7911093@cc.nctu.edu.tw (Erik Wang) writes:
>	Ask two problem about the Laser printer + PostScript.....
>	Who can tell me which program can print two pages text data on
>one side of one paper?  as following:

use

    enscript -2r filename

if you have enscript (AIX does).

>	and by the way, Is there any program which can print text data on
>two side of one paper?

You need a laserprinter capable of that, and I've never seen one
(though I don't doubt they exist).

				--Blair
				  "I'd rather see than be one."
Newsgroups: comp.unix.programmer
From: mikeg@asylum.tmc.edu (Michael Grabenstein)
Subject: programming books
Organization: NASA Goddard Space Flight Center
Distribution: usa
Date: Tue, 29 Dec 1992 18:41:20 GMT

	I am looking for some recommended titles of programming
books. I need to learn BSD Sockets, IOCTL calls, IPC, Semaphores, shared
memory and other advanced topics in 'C' programming on UNIX. (all on 
the same "level" as sockets and IOCTL) 

	Please, e-mail, Thanks :-) I could summarize my findings, if 
there was enough encouragment.

Take care,
	Mike
	mikeg@asylum.gsfc.nasa.gov
=-=-=-=-====-=-=-=-=-=-=-=-=-==-=-=-=-=-=-=
Std. Disclaimers...
Def. Universe -- The largest known Fractal.
			--Personal Theory

Froehliche Weihnachten und ein glueckliches neues Jahr!
From: pmacdon@husc11.harvard.edu (Philip Macdonald)
Newsgroups: comp.unix.programmer
Subject: Help file thing?
Date: 21 Dec 92 15:04:43 GMT
Article-I.D.: husc.pmacdon.724950283


	Hi Folks,

	I'm writing a datebase program and am looking for a way
	to set up a process to run in the "background" while
	the program does other things. I am looking for the 
	best way to achieve this. Is fork the way to go??
	If someone could post an example of how to do this
	I would be most greatful. Or mail me info on this.
	system is Ultrix btw.

		Happy Holidays or Happy First Day O' winter :)
			Phil 

	pmacdon@husc.harvard.edu
	
Newsgroups: comp.unix.programmer
From: hoesel@igc.ethz.ch (Frans van Hoesel)
Subject: complex arithmetic
Organization: University of Groningen, the Netherlands
Date: Thu, 24 Dec 1992 22:28:43 GMT

a simpel question for those who know the answer...
given a complex number as z=ix+y, how does one do
division
if z>w

and what are other 'standard' operations on complex numbers (besides 
*, /, -, +) one expects in a language that would support complex numbers?

I could look it up, but I remember reading something on the news (on some
news group) about doing division correctly (related to rieman surfaces)

any help is greatly appreciated.

-- frans

-- 
--    ==============================================================    --
----  ===  frans van hoesel             hoesel@igc.ethz.ch       ===  ----
--    ==============================================================    --
Newsgroups: comp.unix.programmer,comp.unix.questions
From: pchan@mdd.comm.mot.com (Pat Chan)
Subject: fstat on NFS...
Organization: Motorola - Mobile Data Division; Richmond, BC
Date: Thu, 24 Dec 1992 22:21:47 GMT

I've a question about fstat...

I use fstat to see if a file has been changed or not.

If I change the file, say "file_a" in my own workstation,
fstat reflects the most updated status right away.

But if I change "file_a" in another workstation (eg. on the
NFS server), fstat does not get the most updated 
status until 30 seconds later; unless I close and open
the file again.

Is there any way to solve this problem???

Thanx in advance...



-- 
Pat Chan                          Internet: pchan@mdd.comm.mot.com 
Motorola Mobile Data Division     Voice: (604) 241-6032
11411 Number Five Road            Fax: (604) 241-6042
Richmond, BC Canada V7A 4Z3
Newsgroups: comp.unix.programmer
From: holland@dutiws.twi.tudelft.nl (Gerhard den Hollander)
Subject: having an executable behave like a file
Organization: Delft University of Technology
Date: Tue, 29 Dec 1992 10:29:47 GMT

Hi I have the following problem:

I have a program which reads a file in
(use it as a help test)
while testing this program,
I want the helpfile to be different everytime I use it.
So what I want is some random text generating program (like fortune)
which could be addressed as a file

HELP

Please send me private email

Newsgroups: comp.unix.programmer
From: bdickens@elara.mitre.org (Brian Dickens)
Subject: Pipes/Sockets/Pty's/Communications
Keywords: pipe socket pty
Organization: Research Computer Facility, MITRE Corporation, Bedford, MA
Date: Wed, 30 Dec 1992 16:05:12 GMT

I am attempting to remote-control a program that I did not write, which was
written to get its input from and send its output to a terminal.

I am calling this program from a nice fancy Motif application, written in C.

I want to be able to send commands to the program and get answers back,
but using standard piping techniques have been unable to help me so far,
since the output of the program seems to be *buffered*!!!

What's the best way to set up such a remote-control link?  Should I use
pseudo-terminal devices?  This was one reccomendation I received --
but I haven't a clue what they are or how to use them.  Or are standard
pipes okay, and I'm just doing something wrong?  Let me include the
code I have so far, which tries to start up the program (called ARC/info,
executed by typing "arc") and execute its "help" command... which is
supposed to print a listing to stdout of the commands.

----------------------- CODE PART ----------------------------
#include <stdio.h>

int in, out;

int talkto( cmd )
   char *cmd;
{
   int pid;
   int to_child[2];
   int to_parent[2];

   pipe( to_child );
   pipe( to_parent );
   if( pid = fork(), pid == 0 )
   {
      close( 0 );
      dup( to_parent[0] );
      close( 1 );
      dup( to_child[1] );
      close( to_child[0] );
      close( to_child[1] );
      close( to_parent[0] );
      close( to_parent[1] );
      execlp( cmd, cmd, NULL);
   }
   else
      if( pid > 0 )
      {
         in = dup( to_parent[0] );
         out = dup( to_child[1] );
         close( to_child[0] );
         close( to_child[1] );
         close( to_parent[0] );
         close( to_parent[1] );
      }
      else
      {
         fprintf( stderr, "Couldn't fork process.\n" );
         exit( 1 );
      }

   return( 0 );
}

int main( )
{
   char x[255];

   talkto( "arc" );
   write( out, "help\n", strlen( "help\n" ) );
   read( in, x, 255 );
   printf( "%s", x );
   return( 0 );
}
Newsgroups: comp.unix.programmer,comp.sources.wanted
From: dejesus@archimedes.nwc.navy.mil (Francisco X DeJesus)
Subject: SUMMARY: Get hostname from IP address
Organization: Science Applications International Corp.
Date: Mon, 21 Dec 1992 18:28:04 GMT

A little over a week ago I posted to ask about some way (from the command
line) to get a hostname from an IP address. Here's the results:

A lot of people suggested using nslookup for this. The way to find out
the hostname associated with IP address A.B.C.D with this method is:

nslookup
> set type=ptr
> D.C.B.A.in-addr.arpa

...this works, though it can be a bit tedious. Someone suggested the following
alias to make it simpler:

alias ptr  '( echo set q=PTR ; echo \!$:e.\!$:r:e.\!$:r:r:e.\!$:r:r:r.in-addr.arpa ) | nslookup'

...then, typing "ptr A.B.C.D" from your prompt gives you back the answer
(assuming you had nslookup running to begin with).

I also got a few pointers to a couple of programs out there that may be
handy to have installed: "dig", "host", and "hname" (consult your nearest
archie server). Finally, I received source code in C and Perl for programs
that do the same thing (drop me a line if you want 'em).

Thanks to everyone who replied...

-- 
      Francisco X DeJesus  ----- S A I C -----  dejesus@chinalake.navy.mil
 ------------------------------------------------------------------------------
  * disclaimer: Opinions expressed here are mine. Typos and errors are yours *
 "Duck Season!" "Rabbit Season!" "...rabbit season." "It's Duck Season! SHOOT!"
From: subbarao@fc.hp.com (Kartik Subbarao)
Newsgroups: comp.unix.programmer
Subject: Re: Question on daemon's under inetd
Date: 27 Dec 92 18:30:29 GMT
Reply-To: subbarao@fc.hp.com
Organization: putchar('I'); for (i = 0; i < 3; i++) putchar('E');
Originator: news@nimaster

Once again, I must flame myself for a hastily submitted article (I had to
get on a plane in 30 minutes)

In article <1992Dec24.161716.7183@Princeton.EDU> I wrote:
>In article <1992Dec24.064005.5831@tigger.jvnc.net> aggarwal@tigger.jvnc.net (Vikas Aggarwal) writes:
>>? Can't I reuse the file descr 0 handed to me by 'inetd' ??
>
>You can't issue an accept() on a socket given to you by inetd.
>
>There are two different types of sockets at work here. One type of socket
>is the one connected to the remote end of the connection. It is used as an 
>endpoint of communication, to which you can read and write arbitrary data.
>
>The other type, which I'll call a "server socket", is used to maintain a queue 
>of incoming connections from different hosts to that port. When you issue the 
>listen() call on a socket, it sets the SO_ACCEPTCON flag in it, thus enabling 
>you to accept() on that socket. Writing to or reading from this kind of
>sockets is useless. The only purpose of this socket is to return you
>another socket (from accept()) through which you CAN read and write to the 
>remote host.
>
>Inetd sets up a bunch of these server sockets on the well known ports. When
>an incoming connection from another host is detected, accept() returns
>a socket of the "normal" (read/write type) to inetd, and inetd gives you
>this socket on fd's 0, 1 and 2. 

Everything up to here is correct.

>Note, this socket is bound to a different TCP
>port than the server socket, so that you can potentially have multiple remote
>hosts accessing your service. 

This is bullshit. The reader socket is bound to the same port as the
server socket. As far as the remote host is connected, it's the same
connection. You can still have multiple remote connections accessing your
service since the REMOTE port will be different for each connection.

>Here's where the wait/nowait comes in. If you
>specify wait in /etc/inetd.conf, inetd will NOT allow multiple instances of
>your daemon to run. That is, it will wait until the process is terminated
>before it forks off another instance. If you specify nowait, then it will
>fork off as many requests as it can handle, without waiting for any of them
>to finish. Once again, the socket that inetd returns to you is a normal 
>read/write socket, so you cannot accept() on it, even after the connection is 
>closed. 

This is correct.

>Even if you could, it would be useless, since it is not bound to the 
>well-known port.

This is wrong, just as before.

Sorry 'bout that folks.  Happy holidays! :-)

	-Kartik
From: gt5870c@prism.gatech.EDU (Noah White)
Newsgroups: comp.unix.programmer
Subject: Info Needed on programming w/sockets
Date: 26 Dec 92 22:36:52 GMT
Organization: Universal Exports


    I am starting a program which will use sockets. I have never used them
before but have read and understood the man pages for socket, bind, 
listen etc. However I would like some more indepth information and 
perhaps programming examples for sockets (Internet domain, SOCK_STREM
style). Could anyone point me in the right direction? Thanks!
From: mike@meiko.com (Mike Stok)
Newsgroups: comp.unix.programmer
Subject: termios vs. ioctl (SunOS 4.1.1)
Date: 29 Dec 92 15:14:26 GMT
Organization: Meiko Scientific Corp.

I would like to know what the equivalent code using struct termios
would be for:

  struct sgttyb sg;
  ioctl(fd, TIOCGETP, &sg);
  sg.sg_flags = O_RAW;
  ioctl(fd, TIOCSETP, &sg);

The following fragment comes pretty close, but isn't exactly the same

  tcgetattr (fd, &termios);
  termios.c_iflag &= ~(BRKINT | ISTRIP | IMAXBEL);
  termios.c_oflag &= ~(PARENB | CSIZE);
  termios.c_oflag |= CS8;
  termios.c_iflag &= ~(ICRNL | IXON);
  termios.c_lflag &= ~(ISIG | ICANON | ECHO);
  tcsetattr (fd, TCSANOW, &termios);

Any suggestions would be most welcome (having zipped through various
bits of TFM several times...)

Mike
--
The "usual disclaimers" apply.    |
Mike Stok                         |
mike@meiko.com                    |
Meiko tel: (617) 890 7676         |
Newsgroups: comp.unix.programmer
From: collins.escp10@xerox.com (Anthony Collins)
Subject: Re: sun dkinfo command question
Reply-To: collins.escp10@xerox.com
Organization: Xerox Corporation, El Segundo CA
Date: Mon, 21 Dec 1992 16:55:24 GMT

In article 112411@is.morgan.com, scairns@is.morgan.com (Scott Cairns) writes:
> I'm working on an application that needs to display dkinfo(8) like
> information about disk drives and their partitions.  This is under
> SunOS 4.1.
> 
> So far, I've got it to a point where I can display the starting
> cylinder number, the number of cylinders and the tracks/sector
> for the drive but I need to get more detailed information about
> the partitions.  
> 
> I've been using ioctl(2) to get the above information but what
> calls should I be looking at to get the individual partition
> info?
> 
> Thanks in advance.
> 
> +------------------------------------------------------------------+
> | Scott Cairns           	|   email: scairns@fsg.com         |
> | Fusion Systems Group		|          scairns@is.morgan.com   |
> | New York, New York, USA   	|                                  |
> +------------------------------------------------------------------+
> | Standard disclaimers apply.   				   | 
> +------------------------------------------------------------------+
> | I hope in the future Americans are thought of as a warlike,      |
> | vicious people, because then I bet a lot of high schools would   |
> | pick 'Americans' as their mascot.				   |
> |    					- Jack Handey		   |
> +------------------------------------------------------------------+

I believe you may want to do 'man dkio'.  This should tell you how to
use ioctl(2) to get information from the disk label about partitions
and disk geometry.  I have used the DKIOCGEOM and DKIOCGAPART defines
as arguments to ioctl(2) to get geometry and partition information.

Hope this helps.


---
Anthony Collins
Xerox Corporation
Internet: collins.escp10@xerox.com


Newsgroups: comp.unix.programmer
From: joe@solomon.technet.sg (Joseph Doo)
Subject: FAQ request
X-Newsreader: TIN [version 1.1 PL8]
Date: Fri, 1 Jan 1993 14:04:29 GMT

Need info on FAQ. Help.
Newsgroups: comp.unix.programmer
From: pfferrei@napier.uwaterloo.ca (Paulo Ferreira)
Subject: Getting a copy of "4.3BSD IPC Tutorials"
Organization: University of Waterloo
Date: Mon, 28 Dec 1992 05:41:26 GMT

Where can I ftp a copy of the "Advanced 4.3BSD IPC Tutorials"?

Thanks.


+    Paulo F. Ferreira                        + University of Waterloo +  
+ email: pfferrei@undergrad.math.uwaterloo.ca +    Waterloo, Canada    +
Newsgroups: comp.unix.programmer
From: mcastle@cs.umr.edu (Michael R Castle)
Subject: Assembler systax (and 386 opscodes too, why not?)
Date: Sun, 3 Jan 1993 12:27:06 GMT
Organization: University of Missouri - Rolla, Rolla, MO


I remember seeing one time or another, a reference to a paper describing
the systax used for assembly language programming.  Any pointers would
be greatly appreciated.

regards,
mrc
-- 
Mike Castle .-=NEXUS=-.  Life is like a clock:  You can work constantly
  mcastle@cs.umr.edu     and be right all the time, or not work at all
S087891@UMRVMA.UMR.EDU   and be right at least twice a day.  -- mrc
    We are all of us living in the shadow of Manhattan.  -- Watchmen
Newsgroups: comp.unix.programmer
From: hughes@logos.ucs.indiana.edu (larry hughes)
Subject: Re: Get hostname from IP address
Organization: University Computing Services News
Date: Wed, 23 Dec 1992 13:45:34 GMT

If you don't have the "host" program, try these aliases to make
nslookup a little easier to use:

alias cname     "(" echo set q=CNAME ";" echo \!\* ")" "|" nslookup
alias mx        "(" echo set q=MX ";" echo \!\* ")" "|" nslookup
alias hinfo     "(" echo set q=HINFO ";" echo \!\* ")" "|" nslookup
alias ns        "(" echo set q=NS ";" echo \!\* ")" "|" nslookup
alias any       "(" echo set q=ANY ";" echo \!\* ")" "|" nslookup
alias soa       "(" echo set q=SOA ";" echo \!\* ")" "|" nslookup
alias txt       "(" echo set q=TXT ";" echo \!\* ")" "|" nslookup
alias ptr       "(" echo set q=PTR ";" echo \!\$:e.\!\$:r:e.\!\$:r:r:e.\!\$:r:r:
r.in-addr.arpa ")" "|" nslookup

 //==================================================================\\
||      Larry J. Hughes, Jr.       |        hughes@indiana.edu        || 
||       Indiana University        | "The person who knows everything ||
||  University Computing Services  |        has a lot to learn."      ||
 \\===================================================================//
Xref: sparky comp.unix.programmer:5762 comp.unix.questions:14879 comp.unix.misc:4669