











                             44..44BBSSDD


                          PPrrooggrraammmmeerr''ss


                     SSuupppplleemmeennttaarryy DDooccuummeennttss



                              ((PPSSDD))

















































Now  in  its twentieth year, the USENIX Association, the UNIX and
Advanced Computing Systems professional and  technical  organiza-
tion,  is  a not-for-profit membership association of individuals
and institutions with an interest in UNIX and UNIX-like  systems,
and,  by  extension, C++, X windows, and other advanced tools and
technologies.

USENIX and its members are dedicated to:

+o    fostering innovation and communicating research and  techno-
     logical developments,

+o    sharing ideas and experience relevant to UNIX, UNIX-related,
     and advanced computing systems, and

+o    providing a neutral  forum  for  the  exercise  of  critical
     thought and airing of technical issues.

USENIX  publishes  a  journal  (CCoommppuuttiinngg  SSyysstteemmss), a newsletter
(_;_l_o_g_i_n_:), Proceedings from its  frequent  Conferences  and  Sym-
posia, and a Book Series.

SAGE, The Systems Administrators Guild, a Special Technical Group
with the USENIX Association, is dedicated to the  advancement  of
system administration as a profession.

SAGE brings together systems managers and administrators to:

+o    propagate knowledge of good professional practice,

+o    recruit talented individuals to the profession,

+o    recognize individuals who attain professional excellence,

+o    foster  technical development and share solutions to techni-
     cal problems, and

+o    communicate in an organized voice  with  users,  management,
     and vendors on system administration topics.
























=1 .if 0 .tl ''''





                             44..44BBSSDD


                          PPrrooggrraammmmeerr''ss


                     SSuupppplleemmeennttaarryy DDooccuummeennttss



                              ((PPSSDD))








                 BBeerrkkeelleeyy SSooffttwwaarree DDiissttrriibbuuttiioonn


                           AApprriill,, 11999944








                 CCoommppuutteerr SSyysstteemmss RReesseeaarrcchh GGrroouupp

              UUnniivveerrssiittyy ooff CCaalliiffoorrnniiaa aatt BBeerrkkeelleeyy














                    AA UUSSEENNIIXX AAssssoocciiaattiioonn BBooookk
                   OO''RReeiillllyy && AAssssoocciiaatteess,, IInncc..
                   110033 MMoorrrriiss SSttrreeeett,, SSuuiittee AA












                      SSeebbaassttooppooll,, CCAA 9944557722

































































First Printing, 1994
Second Printing, 1995



Copyright  1979,  1980, 1983, 1986, 1988, 1989, 1991, 1992, 1993,
1994 The Regents of the University  of  California.   All  rights
reserved.



Other  than  the specific manual pages and documents listed below
as copyrighted by AT&T, redistribution and use of this manual  in
source  and  binary forms, with or without modification, are per-
mitted provided that the following conditions are met:

1)   Redistributions of this manual  must  retain  the  copyright
     notices  on  this page, this list of conditions and the fol-
     lowing disclaimer.

2)   Software or documentation that  incorporates  part  of  this
     manual  must  reproduce  the copyright notices on this page,
     this list of conditions and the following disclaimer in  the
     documentation  and/or other materials provided with the dis-
     tribution.

3)   All advertising materials mentioning features or use of this
     software  must display the following acknowledgement: ``This
     product includes software developed  by  the  University  of
     California, Berkeley and its contributors.''

4)   Neither the name of the University nor the names of its con-
     tributors may be used to endorse or promote products derived
     from  this  software  without specific prior written permis-
     sion.

TTHHIISS SSOOFFTTWWAARREE IISS PPRROOVVIIDDEEDD BBYY TTHHEE RREEGGEENNTTSS  AANNDD  CCOONNTTRRIIBBUUTTOORRSS  ````AASS
IISS''''  AANNDD  AANNYY  EEXXPPRREESSSS OORR IIMMPPLLIIEEDD WWAARRRRAANNTTIIEESS,, IINNCCLLUUDDIINNGG,, BBUUTT NNOOTT
LLIIMMIITTEEDD TTOO,, TTHHEE IIMMPPLLIIEEDD WWAARRRRAANNTTIIEESS OOFF MMEERRCCHHAANNTTAABBIILLIITTYY AANNDD FFIITTNNEESSSS
FFOORR  AA  PPAARRTTIICCUULLAARR PPUURRPPOOSSEE AARREE DDIISSCCLLAAIIMMEEDD..  IINN NNOO EEVVEENNTT SSHHAALLLL TTHHEE
RREEGGEENNTTSS OORR CCOONNTTRRIIBBUUTTOORRSS BBEE LLIIAABBLLEE FFOORR AANNYY DDIIRREECCTT,, IINNDDIIRREECCTT,, IINNCCII--
DDEENNTTAALL,,  SSPPEECCIIAALL,, EEXXEEMMPPLLAARRYY,, OORR CCOONNSSEEQQUUEENNTTIIAALL DDAAMMAAGGEESS ((IINNCCLLUUDDIINNGG,,
BBUUTT NNOOTT LLIIMMIITTEEDD TTOO,, PPRROOCCUURREEMMEENNTT OOFF SSUUBBSSTTIITTUUTTEE GGOOOODDSS OORR  SSEERRVVIICCEESS;;
LLOOSSSS  OOFF UUSSEE,, DDAATTAA,, OORR PPRROOFFIITTSS;; OORR BBUUSSIINNEESSSS IINNTTEERRRRUUPPTTIIOONN)) HHOOWWEEVVEERR
CCAAUUSSEEDD AANNDD OONN AANNYY  TTHHEEOORRYY  OOFF  LLIIAABBIILLIITTYY,,  WWHHEETTHHEERR  IINN  CCOONNTTRRAACCTT,,
SSTTRRIICCTT  LLIIAABBIILLIITTYY,,  OORR  TTOORRTT  ((IINNCCLLUUDDIINNGG NNEEGGLLIIGGEENNCCEE OORR OOTTHHEERRWWIISSEE))
AARRIISSIINNGG IINN AANNYY WWAAYY OOUUTT OOFF TTHHEE  UUSSEE  OOFF  TTHHIISS  SSOOFFTTWWAARREE,,  EEVVEENN  IIFF
AADDVVIISSEEDD OOFF TTHHEE PPOOSSSSIIBBIILLIITTYY OOFF SSUUCCHH DDAAMMAAGGEE..



Documents  PSD:1,  2,  3,  4, 6, 11, 15, 16, and 17 are copyright
1979, AT&T Bell Laboratories, Incorporated.  Document PSD:8 is  a
modification  of  an earlier document that is copyrighted 1979 by












AT&T Bell Laboratories,  Incorporated.   Holders  of  UNIXTM/32V,
System  III,  or System V software licenses are permitted to copy
these documents,  or  any  portion  of  them,  as  necessary  for
licensed  use of the software, provided this copyright notice and
statement of permission are included.


Document PSD:10 is part of the user contributed software  and  is
copyright  1992 by the Free Software Foundation, Inc.  Permission
is granted to make and distribute verbatim copies of  this  docu-
ment provided the copyright notice and this permission notice are
preserved on all copies.


Document PSD:13 is part of the user contributed software  and  is
copyright  1983  by  Walter F. Tichy.  Permission to copy the RCS
documentation or any portion thereof as  necessary  for  licensed
use  of  the  software  is granted to licensees of this software,
provided this copyright notice is included.



The views and conclusions contained in this manual are  those  of
the  authors  and should not be interpreted as representing offi-
cial policies, either expressed or implied, of the Regents of the
University of California.



The 4.4BSD Daemon used on the cover is copyright 1994 by Marshall
Kirk McKusick and is reproduced with permission.
This book was printed and bound in the United States of  America.
Distributed by O'Reilly & Associates, Inc.


[recycle logo]  This  book is printed on acid-free paper with 50%
                recycled  content,  10-13%  post-consumer  waste.
                O'Reilly & Associates is committed to using paper
                with the highest recycled content available  con-
                sistent with high quality.


ISBN: 1-56592-079-1




























                            CCoonntteennttss



Introduction                                                   ix


DDooccuummeennttss ooff HHiissttoorriiccaall IInntteerreesstt


The Unix Time-Sharing System                             tabbed 1

     Dennis  Ritchie and Ken Thompson's original paper about
     UNIX, reprinted from Communications of the ACM.


Unix Implementation                                      tabbed 2

     Ken Thompson's description of the implementation of the
     Version 7 kernel and file system.


The Unix I/O System                                      tabbed 3

     Dennis  Ritchie's overview of the I/O System of Version
     7; still helpful for those writing device drivers.


Unix Programming - Second Edition                        tabbed 4

     Describes the programming interface to the UNIX version
     7  operating  system  and  the  standard  I/O  library.
     Should be supplemented by  Kernighan  and  Pike,  ``The
     UNIX Programming Environment'', Prentice-Hall, 1984 and
     especially by the Programmer Reference Manual section 2
     (system calls) and 3 (library routines).


Berkeley Software Architecture Manual (4.4 Edition)      tabbed 5

     A  concise  and  terse  description  of the system call
     interface provided in Berkeley  Unix,  as  revised  for
     4.4BSD.  This will never be a best seller.


LLaanngguuaaggeess iinn ccoommmmoonn uussee












- viii -                                                 Contents


The C Programming Language - Reference Manual            tabbed 6

     Official  statement of the syntax of C.  Should be sup-
     plemented  by  ``The  C  Programming  Language,''  B.W.
     Kernighan  and  D.M. Ritchie, Prentice-Hall, 1978, that
     contains a tutorial introduction and many examples.


Berkeley Pascal User's Manual                            tabbed 7

     An implementation of this language popular for learning
     to program.


A Portable Fortran 77 Compiler                           tabbed 8

     A  revised  version  of  the  document which originally
     appeared in Volume 2b of the Bell  Labs  documentation;
     this version reflects the work done at Berkeley.


Introduction to the f77 I/O Library                      tabbed 9

     A  description  of the revised input/output library for
     Fortran 77, reflecting work carried out at Berkeley.


PPrrooggrraammmmiinngg TToooollss


Debugging with GDB: The GNU Source-Level Debugger       tabbed 10

     How to debug programs using the source level _g_d_b debug-
     ger  (or  how  to debug programs without having to know
     much about machine language).


A Tutorial Introduction to ADB                          tabbed 11

     How to debug programs using the assembly-language level
     _a_d_b debugger.


Make - A Program for Maintaining Computer Programs      tabbed 12

     Indispensable  tool  for making sure large programs are
     properly compiled with minimal effort.


An Introduction to the Revision Control System          tabbed 13

     RCS is a user-contributed  tool  for  working  together
     with  other  people  without  stepping  on each other's
     toes.  An alternative to _s_c_c_s for controlling  software









Contents                                                   - ix -


     changes.


An Introduction to the Source Code Control System       tabbed 14

     A  useful  introductory  article  for  those users with
     installations licensed for SCCS.


YACC: Yet Another Compiler-Compiler                     tabbed 15

     Converts a BNF specification of a language and semantic
     actions written in C into a compiler for that language.


LEX - A Lexical Analyzer Generator                      tabbed 16

     Creates a recognizer for a set of regular  expressions:
     each  regular expression can be followed by arbitrary C
     code to be executed upon finding  the  regular  expres-
     sion.


The M4 Macro Processor                                  tabbed 17

     M4  is a macro processor useful in its own right and as
     a front-end for C, Ratfor, and Cobol.


gprof: a Call Graph Execution Profiler                  tabbed 18

     A program to show the call graph and execution time  of
     a program.  Indispensable aid for improving the running
     time of almost everything.


PPrrooggrraammmmiinngg LLiibbrraarriieess


Screen Updating and Cursor Movement Optimization        tabbed 19

     Describes  the  _c_u_r_s_e_s  package,  an  aid  for  writing
     screen-oriented, terminal-independent programs.


GGeenneerraall RReeffeerreennccee


An Introductory 4.4BSD Interprocess Communication Tutoriatlabbed 20

     How  to write programs that use the Interprocess Commu-
     nication Facilities of 4.4BSD.











- x -                                                    Contents


An Advanced 4.4BSD Interprocess Communication Tutorial  tabbed 21

     The reference document (with  some  examples)  for  the
     Interprocess Communication Facilities of 4.4BSD.


List of Documents                               inside back cover



























































                             IInnttrroodduuccttiioonn



The  documentation  for  4.4BSD is in a format similar to the one
used for the 4.2BSD and 4.3BSD manuals.  It is divided into three
sets;  each  set  consists of one or more volumes.  The abbrevia-
tions for the volume names are listed  in  square  brackets;  the
abbreviations  for the manual sections are listed in parenthesis.

     I. User's Documents
          User's Reference Manual [URM]
               Commands (1)
               Games (6)
               Macro packages and language conventions (7)
          User's Supplementary Documents [USD]
               Getting Started
               Basic Utilities
               Communicating with the World
               Text Editing
               Document Preparation
               Amusements

     II. Programmer's Documents
          Programmer's Reference Manual [PRM]
               System calls (2)
               Subroutines (3)
               Special files (4)
               File formats and conventions (5)
          Programmer's Supplementary Documents [PSD]
               Documents of Historic Interest
               Languages in common use
               Programming Tools
               Programming Libraries
               General Reference

     III. System Manager's Manual [SMM]
          Maintenance commands (8)
          System Installation and Administration


References to individual documents are  given  as  ``volume:docu-
ment'',  thus  USD:1 refers to the first document in the ``User's
Supplementary Documents''.  References to manual pages are  given
as  ``_n_a_m_e(section)'' thus _s_h(1) refers to the shell manual entry
in section 1.

The manual pages give descriptions of the features of the  4.4BSD
system, as developed at the University of California at Berkeley.
They do not attempt to provide perspective or  tutorial  informa-
tion  about  the  4.4BSD operating system, its facilities, or its
implementation.  Various documents on those topics are  contained
in  the ``UNIX User's Supplementary Documents'' (USD), the ``UNIX
Programmer's Supplementary Documents'' (PSD), and  ``UNIX  System









- xii -                                              Introduction


Manager's  Manual''  (SMM).   In  particular, for an overview see
``The UNIX Time-Sharing System'' (PSD:1) by Ritchie and Thompson;
for  a  tutorial see ``UNIX for Beginners'' (USD:1) by Kernighan,
and for an guide to the new features of this latest version,  see
``Berkeley  Software Architecture Manual (4.4 Edition)'' (PSD:5).

Within the area it surveys, this volume attempts  to  be  timely,
complete  and concise.  Where the latter two objectives conflict,
the obvious is often left unsaid in  favor  of  brevity.   It  is
intended  that  each  program  be  described  as it is, not as it
should be.  Inevitably, this means  that  various  sections  will
soon be out of date.

Commands  are  programs  intended  to  be invoked directly by the
user, in contrast to subroutines, that are intended to be  called
by  the user's programs.  User commands are described in URM sec-
tion 1.  Commands generally reside in directory _/_b_i_n (for  _b_i_nary
programs).   Some programs also reside in _/_u_s_r_/_b_i_n_, to save space
in _/_b_i_n_.  These directories are  searched  automatically  by  the
command  interpreters.   Additional  directories  that  may be of
interest include _/_u_s_r_/_c_o_n_t_r_i_b_/_b_i_n_, which has contributed software
_/_u_s_r_/_o_l_d_/_b_i_n_,  which  has old but sometimes still useful software
and _/_u_s_r_/_l_o_c_a_l_/_b_i_n_, which contains software local to your site.

Games have been relegated to URM section  6  and  _/_u_s_r_/_g_a_m_e_s_,  to
keep  them  from  contaminating the more staid information of URM
section 1.

Miscellaneous collection of information necessary for writing  in
various  specialized  languages  such  as  character codes, macro
packages for typesetting, etc is contained in URM section 7.

System calls are entries into the BSD kernel.   The  system  call
interface is identical to a C language procedure call; the equiv-
alent C procedures are described in PRM section 2.

An assortment of subroutines is available; they are described  in
PRM  section 3.  The primary libraries in which they are kept are
described in _i_n_t_r_o(3).  The functions are described in  terms  of
C.

PRM  section  4  discusses  the  characteristics  of  each system
``file'' that refers to an I/O device.  The names in this section
refer  to the HP300 device names for the hardware, instead of the
names of the special files themselves.

The file formats and conventions (PRM section  5)  documents  the
structure  of particular kinds of files; for example, the form of
the output of the loader and assembler is  given.   Excluded  are
files  used  by  only  one  command,  for example the assembler's
intermediate files.

Commands and procedures intended for use primarily by the  system
administrator   are  described  in  SMM  section  8.   The  files









Introduction                                             - xiii -


described here are almost all kept in the  directory  _/_e_t_c_.   The
system administration binaries reside in _/_s_b_i_n_, and _/_u_s_r_/_s_b_i_n_.

Each  section  consists  of  independent  entries of a page or so
each.  The name of the entry is  in  the  upper  corners  of  its
pages,  together  with  the  section number.  Entries within each
section are alphabetized.  The page numbers of each  entry  start
at  1;  it  is  infeasible to number consecutively the pages of a
document like this that is republished in many variant forms.

All entries are based on a common  format;  not  all  subsections
always appear.

     The  _n_a_m_e  subsection  lists the exact names of the commands
     and subroutines covered under the entry and  gives  a  short
     description of their purpose.

     The  _s_y_n_o_p_s_i_s  summarizes  the  use  of  the  program  being
     described.  A few conventions are used, particularly in  the
     Commands subsection:

          BBoollddffaaccee  words  are considered literals, and are typed
          just as they appear.

          Square brackets [ ] around an argument  show  that  the
          argument  is  optional.   When  an argument is given as
          ``name'', it always refers to a file name.

          Ellipses ``...'' are used to  show  that  the  previous
          argument-prototype may be repeated.

          A  final convention is used by the commands themselves.
          An argument beginning with a minus sign  ``-''  usually
          means that it is an option-specifying argument, even if
          it appears in  a  position  where  a  file  name  could
          appear.   Therefore,  it  is unwise to have files whose
          names begin with ``-''.

     The _d_e_s_c_r_i_p_t_i_o_n subsection discusses in detail  the  subject
     at hand.

     The _f_i_l_e_s subsection gives the names of files that are built
     into the program.

     A _s_e_e _a_l_s_o subsection gives pointers to related information.

     A  _d_i_a_g_n_o_s_t_i_c_s  subsection  discusses the diagnostic indica-
     tions that may be produced.  Messages that are  intended  to
     be self-explanatory are not listed.

     The _b_u_g_s subsection gives known bugs and sometimes deficien-
     cies.  Occasionally the suggested fix is also described.











- xiv -                                              Introduction


At the beginning of URM, PRM, and SSM is a List of Manual  Pages,
organized  by section and alphabetically within each section, and
a Permuted Index derived  from  that  List.   Within  each  index
entry, the title of the writeup to which it refers is followed by
the appropriate section number  in  parentheses.   This  fact  is
important  because  there  is considerable name duplication among
the sections, arising principally from commands that  exist  only
to  exercise  a particular system call.  Finally, there is a list
of documents on the inside back cover of each volume.



















































