~pythonregexp2.7/python/issue2636-01+09-02

« back to all changes in this revision

Viewing changes to Doc/library/os.rst

  • Committer: Jeffrey C. "The TimeHorse" Jacobs
  • Date: 2008-09-22 00:16:16 UTC
  • mfrom: (39022.1.34 Regexp-2.7)
  • Revision ID: darklord@timehorse.com-20080922001616-p1wdip9lfp0zl5cu
Merged in changes from the Atomic Grouping / Possessive Qualifiers branch.

Show diffs side-by-side

added added

removed removed

Lines of Context:
24
24
 
25
25
.. note::
26
26
 
 
27
   If not separately noted, all functions that claim "Availability: Unix" are
 
28
   supported on Mac OS X, which builds on a Unix core.
 
29
 
 
30
.. note::
 
31
 
27
32
   All functions in this module raise :exc:`OSError` in the case of invalid or
28
33
   inaccessible file names and paths, or other arguments that have the correct
29
34
   type, but are not accepted by the operating system.
44
49
.. data:: path
45
50
 
46
51
   The corresponding operating system dependent standard module for pathname
47
 
   operations, such as :mod:`posixpath` or :mod:`macpath`.  Thus, given the proper
 
52
   operations, such as :mod:`posixpath` or :mod:`ntpath`.  Thus, given the proper
48
53
   imports, ``os.path.split(file)`` is equivalent to but more portable than
49
54
   ``posixpath.split(file)``.  Note that this is also an importable module: it may
50
55
   be imported directly as :mod:`os.path`.
81
86
 
82
87
   .. note::
83
88
 
84
 
      On some platforms, including FreeBSD and Mac OS X, setting ``environ`` may cause
85
 
      memory leaks.  Refer to the system documentation for :cfunc:`putenv`.
 
89
      On some platforms, including FreeBSD and Mac OS X, setting ``environ`` may
 
90
      cause memory leaks.  Refer to the system documentation for
 
91
      :cfunc:`putenv`.
86
92
 
87
93
   If :func:`putenv` is not provided, a modified copy of this mapping  may be
88
94
   passed to the appropriate process-creation functions to cause  child processes
202
208
 
203
209
   .. note::
204
210
 
205
 
      On some platforms, including FreeBSD and Mac OS X, setting ``environ`` may cause
206
 
      memory leaks. Refer to the system documentation for putenv.
 
211
      On some platforms, including FreeBSD and Mac OS X, setting ``environ`` may
 
212
      cause memory leaks. Refer to the system documentation for putenv.
207
213
 
208
214
   When :func:`putenv` is supported, assignments to items in ``os.environ`` are
209
215
   automatically translated into corresponding calls to :func:`putenv`; however,
338
344
 
339
345
   Return an open file object connected to the file descriptor *fd*.  The *mode*
340
346
   and *bufsize* arguments have the same meaning as the corresponding arguments to
341
 
   the built-in :func:`open` function. Availability: Macintosh, Unix, Windows.
 
347
   the built-in :func:`open` function. Availability: Unix, Windows.
342
348
 
343
349
   .. versionchanged:: 2.3
344
350
      When specified, the *mode* argument must now start with one of the letters
359
365
   status of the command (encoded in the format specified for :func:`wait`) is
360
366
   available as the return value of the :meth:`close` method of the file object,
361
367
   except that when the exit status is zero (termination without errors), ``None``
362
 
   is returned. Availability: Macintosh, Unix, Windows.
 
368
   is returned. Availability: Unix, Windows.
363
369
 
364
370
   .. deprecated:: 2.6
365
 
      This function is obsolete.  Use the :mod:`subprocess` module.
 
371
      This function is obsolete.  Use the :mod:`subprocess` module.  Check 
 
372
      especially the :ref:`subprocess-replacements` section.
366
373
 
367
374
   .. versionchanged:: 2.0
368
375
      This function worked unreliably under Windows in earlier versions of Python.
375
382
 
376
383
   Return a new file object opened in update mode (``w+b``).  The file has no
377
384
   directory entries associated with it and will be automatically deleted once
378
 
   there are no file descriptors for the file. Availability: Macintosh, Unix,
 
385
   there are no file descriptors for the file. Availability: Unix,
379
386
   Windows.
380
387
 
381
388
There are a number of different :func:`popen\*` functions that provide slightly
411
418
   child_stdout)``.
412
419
 
413
420
   .. deprecated:: 2.6
414
 
      All of the :func:`popen\*` functions are obsolete. Use the :mod:`subprocess`
415
 
      module.
 
421
      This function is obsolete.  Use the :mod:`subprocess` module.  Check 
 
422
      especially the :ref:`subprocess-replacements` section.
416
423
 
417
 
   Availability: Macintosh, Unix, Windows.
 
424
   Availability: Unix, Windows.
418
425
 
419
426
   .. versionadded:: 2.0
420
427
 
425
432
   child_stdout, child_stderr)``.
426
433
 
427
434
   .. deprecated:: 2.6
428
 
      All of the :func:`popen\*` functions are obsolete. Use the :mod:`subprocess`
429
 
      module.
 
435
      This function is obsolete.  Use the :mod:`subprocess` module.  Check 
 
436
      especially the :ref:`subprocess-replacements` section.
430
437
 
431
 
   Availability: Macintosh, Unix, Windows.
 
438
   Availability: Unix, Windows.
432
439
 
433
440
   .. versionadded:: 2.0
434
441
 
439
446
   child_stdout_and_stderr)``.
440
447
 
441
448
   .. deprecated:: 2.6
442
 
      All of the :func:`popen\*` functions are obsolete. Use the :mod:`subprocess`
443
 
      module.
 
449
      This function is obsolete.  Use the :mod:`subprocess` module.  Check 
 
450
      especially the :ref:`subprocess-replacements` section.
444
451
 
445
 
   Availability: Macintosh, Unix, Windows.
 
452
   Availability: Unix, Windows.
446
453
 
447
454
   .. versionadded:: 2.0
448
455
 
472
479
 
473
480
.. function:: close(fd)
474
481
 
475
 
   Close file descriptor *fd*. Availability: Macintosh, Unix, Windows.
 
482
   Close file descriptor *fd*. Availability: Unix, Windows.
476
483
 
477
484
   .. note::
478
485
 
485
492
.. function:: closerange(fd_low, fd_high)
486
493
 
487
494
   Close all file descriptors from *fd_low* (inclusive) to *fd_high* (exclusive),
488
 
   ignoring errors. Availability: Macintosh, Unix, Windows. Equivalent to::
 
495
   ignoring errors. Availability: Unix, Windows. Equivalent to::
489
496
 
490
497
      for fd in xrange(fd_low, fd_high):
491
498
          try:
498
505
 
499
506
.. function:: dup(fd)
500
507
 
501
 
   Return a duplicate of file descriptor *fd*. Availability: Macintosh, Unix,
 
508
   Return a duplicate of file descriptor *fd*. Availability: Unix,
502
509
   Windows.
503
510
 
504
511
 
505
512
.. function:: dup2(fd, fd2)
506
513
 
507
514
   Duplicate file descriptor *fd* to *fd2*, closing the latter first if necessary.
508
 
   Availability: Macintosh, Unix, Windows.
 
515
   Availability: Unix, Windows.
509
516
 
510
517
 
511
518
.. function:: fchmod(fd, mode)
540
547
   additional names as well.  The names known to the host operating system are
541
548
   given in the ``pathconf_names`` dictionary.  For configuration variables not
542
549
   included in that mapping, passing an integer for *name* is also accepted.
543
 
   Availability: Macintosh, Unix.
 
550
   Availability: Unix.
544
551
 
545
552
   If *name* is a string and is not known, :exc:`ValueError` is raised.  If a
546
553
   specific value for *name* is not supported by the host system, even if it is
551
558
.. function:: fstat(fd)
552
559
 
553
560
   Return status for file descriptor *fd*, like :func:`stat`. Availability:
554
 
   Macintosh, Unix, Windows.
 
561
   Unix, Windows.
555
562
 
556
563
 
557
564
.. function:: fstatvfs(fd)
567
574
 
568
575
   If you're starting with a Python file object *f*, first do ``f.flush()``, and
569
576
   then do ``os.fsync(f.fileno())``, to ensure that all internal buffers associated
570
 
   with *f* are written to disk. Availability: Macintosh, Unix, and Windows
 
577
   with *f* are written to disk. Availability: Unix, and Windows
571
578
   starting in 2.2.3.
572
579
 
573
580
 
574
581
.. function:: ftruncate(fd, length)
575
582
 
576
583
   Truncate the file corresponding to file descriptor *fd*, so that it is at most
577
 
   *length* bytes in size. Availability: Macintosh, Unix.
 
584
   *length* bytes in size. Availability: Unix.
578
585
 
579
586
 
580
587
.. function:: isatty(fd)
581
588
 
582
589
   Return ``True`` if the file descriptor *fd* is open and connected to a
583
 
   tty(-like) device, else ``False``. Availability: Macintosh, Unix.
 
590
   tty(-like) device, else ``False``. Availability: Unix.
584
591
 
585
592
 
586
593
.. function:: lseek(fd, pos, how)
589
596
   by *how*: :const:`SEEK_SET` or ``0`` to set the position relative to the
590
597
   beginning of the file; :const:`SEEK_CUR` or ``1`` to set it relative to the
591
598
   current position; :const:`os.SEEK_END` or ``2`` to set it relative to the end of
592
 
   the file. Availability: Macintosh, Unix, Windows.
 
599
   the file. Availability: Unix, Windows.
593
600
 
594
601
 
595
602
.. function:: open(file, flags[, mode])
597
604
   Open the file *file* and set various flags according to *flags* and possibly its
598
605
   mode according to *mode*. The default *mode* is ``0777`` (octal), and the
599
606
   current umask value is first masked out.  Return the file descriptor for the
600
 
   newly opened file. Availability: Macintosh, Unix, Windows.
 
607
   newly opened file. Availability: Unix, Windows.
601
608
 
602
609
   For a description of the flag and mode values, see the C run-time documentation;
603
610
   flag constants (like :const:`O_RDONLY` and :const:`O_WRONLY`) are defined in
617
624
 
618
625
   Open a new pseudo-terminal pair. Return a pair of file descriptors ``(master,
619
626
   slave)`` for the pty and the tty, respectively. For a (slightly) more portable
620
 
   approach, use the :mod:`pty` module. Availability: Macintosh, some flavors of
 
627
   approach, use the :mod:`pty` module. Availability: some flavors of
621
628
   Unix.
622
629
 
623
630
 
624
631
.. function:: pipe()
625
632
 
626
633
   Create a pipe.  Return a pair of file descriptors ``(r, w)`` usable for reading
627
 
   and writing, respectively. Availability: Macintosh, Unix, Windows.
 
634
   and writing, respectively. Availability: Unix, Windows.
628
635
 
629
636
 
630
637
.. function:: read(fd, n)
631
638
 
632
639
   Read at most *n* bytes from file descriptor *fd*. Return a string containing the
633
640
   bytes read.  If the end of the file referred to by *fd* has been reached, an
634
 
   empty string is returned. Availability: Macintosh, Unix, Windows.
 
641
   empty string is returned. Availability: Unix, Windows.
635
642
 
636
643
   .. note::
637
644
 
645
652
.. function:: tcgetpgrp(fd)
646
653
 
647
654
   Return the process group associated with the terminal given by *fd* (an open
648
 
   file descriptor as returned by :func:`open`). Availability: Macintosh, Unix.
 
655
   file descriptor as returned by :func:`open`). Availability: Unix.
649
656
 
650
657
 
651
658
.. function:: tcsetpgrp(fd, pg)
652
659
 
653
660
   Set the process group associated with the terminal given by *fd* (an open file
654
 
   descriptor as returned by :func:`open`) to *pg*. Availability: Macintosh, Unix.
 
661
   descriptor as returned by :func:`open`) to *pg*. Availability: Unix.
655
662
 
656
663
 
657
664
.. function:: ttyname(fd)
658
665
 
659
666
   Return a string which specifies the terminal device associated with
660
667
   file descriptor *fd*.  If *fd* is not associated with a terminal device, an
661
 
   exception is raised. Availability:Macintosh, Unix.
 
668
   exception is raised. Availability: Unix.
662
669
 
663
670
 
664
671
.. function:: write(fd, str)
665
672
 
666
673
   Write the string *str* to file descriptor *fd*. Return the number of bytes
667
 
   actually written. Availability: Macintosh, Unix, Windows.
 
674
   actually written. Availability: Unix, Windows.
668
675
 
669
676
   .. note::
670
677
 
689
696
          O_TRUNC
690
697
 
691
698
   Options for the *flag* argument to the :func:`open` function. These can be
692
 
   combined using the bitwise OR operator ``|``. Availability: Macintosh, Unix, Windows.
 
699
   combined using the bitwise OR operator ``|``. Availability: Unix, Windows.
693
700
 
694
701
 
695
702
.. data:: O_DSYNC
702
709
          O_EXLOCK
703
710
 
704
711
   More options for the *flag* argument to the :func:`open` function. Availability:
705
 
   Macintosh, Unix.
 
712
   Unix.
706
713
 
707
714
 
708
715
.. data:: O_BINARY
732
739
          SEEK_END
733
740
 
734
741
   Parameters to the :func:`lseek` function. Their values are 0, 1, and 2,
735
 
   respectively. Availability: Windows, Macintosh, Unix.
 
742
   respectively. Availability: Windows, Unix.
736
743
 
737
744
   .. versionadded:: 2.5
738
745
 
751
758
   can be the inclusive OR of one or more of :const:`R_OK`, :const:`W_OK`, and
752
759
   :const:`X_OK` to test permissions.  Return :const:`True` if access is allowed,
753
760
   :const:`False` if not. See the Unix man page :manpage:`access(2)` for more
754
 
   information. Availability: Macintosh, Unix, Windows.
 
761
   information. Availability: Unix, Windows.
755
762
 
756
763
   .. note::
757
764
 
795
802
 
796
803
   .. index:: single: directory; changing
797
804
 
798
 
   Change the current working directory to *path*. Availability: Macintosh, Unix,
 
805
   Change the current working directory to *path*. Availability: Unix,
799
806
   Windows.
800
807
 
801
808
 
811
818
.. function:: getcwd()
812
819
 
813
820
   Return a string representing the current working directory. Availability:
814
 
   Macintosh, Unix, Windows.
 
821
   Unix, Windows.
815
822
 
816
823
 
817
824
.. function:: getcwdu()
818
825
 
819
826
   Return a Unicode object representing the current working directory.
820
 
   Availability: Macintosh, Unix, Windows.
 
827
   Availability: Unix, Windows.
821
828
 
822
829
   .. versionadded:: 2.3
823
830
 
838
845
   * ``SF_NOUNLINK``
839
846
   * ``SF_SNAPSHOT``
840
847
 
841
 
   Availability: Macintosh, Unix.
 
848
   Availability: Unix.
842
849
 
843
850
   .. versionadded:: 2.6
844
851
 
846
853
.. function:: chroot(path)
847
854
 
848
855
   Change the root directory of the current process to *path*. Availability:
849
 
   Macintosh, Unix.
 
856
   Unix.
850
857
 
851
858
   .. versionadded:: 2.2
852
859
 
878
885
   * ``stat.S_IWOTH``
879
886
   * ``stat.S_IXOTH``
880
887
 
881
 
   Availability: Macintosh, Unix, Windows.
 
888
   Availability: Unix, Windows.
882
889
 
883
890
   .. note::
884
891
 
891
898
.. function:: chown(path, uid, gid)
892
899
 
893
900
   Change the owner and group id of *path* to the numeric *uid* and *gid*. To leave
894
 
   one of the ids unchanged, set it to -1. Availability: Macintosh, Unix.
 
901
   one of the ids unchanged, set it to -1. Availability: Unix.
895
902
 
896
903
 
897
904
.. function:: lchflags(path, flags)
914
921
.. function:: lchown(path, uid, gid)
915
922
 
916
923
   Change the owner and group id of *path* to the numeric *uid* and *gid*. This
917
 
   function will not follow symbolic links. Availability: Macintosh, Unix.
 
924
   function will not follow symbolic links. Availability: Unix.
918
925
 
919
926
   .. versionadded:: 2.3
920
927
 
921
928
 
922
929
.. function:: link(src, dst)
923
930
 
924
 
   Create a hard link pointing to *src* named *dst*. Availability: Macintosh, Unix.
 
931
   Create a hard link pointing to *src* named *dst*. Availability: Unix.
925
932
 
926
933
 
927
934
.. function:: listdir(path)
928
935
 
929
936
   Return a list containing the names of the entries in the directory. The list is
930
937
   in arbitrary order.  It does not include the special entries ``'.'`` and
931
 
   ``'..'`` even if they are present in the directory. Availability: Macintosh,
 
938
   ``'..'`` even if they are present in the directory. Availability:
932
939
   Unix, Windows.
933
940
 
934
941
   .. versionchanged:: 2.3
947
954
 
948
955
   Create a FIFO (a named pipe) named *path* with numeric mode *mode*.  The default
949
956
   *mode* is ``0666`` (octal).  The current umask value is first masked out from
950
 
   the mode. Availability: Macintosh, Unix.
 
957
   the mode. Availability: Unix.
951
958
 
952
959
   FIFOs are pipes that can be accessed like regular files.  FIFOs exist until they
953
960
   are deleted (for example with :func:`os.unlink`). Generally, FIFOs are used as
997
1004
 
998
1005
   Create a directory named *path* with numeric mode *mode*. The default *mode* is
999
1006
   ``0777`` (octal).  On some systems, *mode* is ignored.  Where it is used, the
1000
 
   current umask value is first masked out. Availability: Macintosh, Unix, Windows.
 
1007
   current umask value is first masked out. Availability: Unix, Windows.
1001
1008
 
1002
1009
   It is also possible to create temporary directories; see the
1003
1010
   :mod:`tempfile` module's :func:`tempfile.mkdtemp` function.
1035
1042
   additional names as well.  The names known to the host operating system are
1036
1043
   given in the ``pathconf_names`` dictionary.  For configuration variables not
1037
1044
   included in that mapping, passing an integer for *name* is also accepted.
1038
 
   Availability: Macintosh, Unix.
 
1045
   Availability: Unix.
1039
1046
 
1040
1047
   If *name* is a string and is not known, :exc:`ValueError` is raised.  If a
1041
1048
   specific value for *name* is not supported by the host system, even if it is
1048
1055
   Dictionary mapping names accepted by :func:`pathconf` and :func:`fpathconf` to
1049
1056
   the integer values defined for those names by the host operating system.  This
1050
1057
   can be used to determine the set of names known to the system. Availability:
1051
 
   Macintosh, Unix.
 
1058
   Unix.
1052
1059
 
1053
1060
 
1054
1061
.. function:: readlink(path)
1061
1068
   .. versionchanged:: 2.6
1062
1069
      If the *path* is a Unicode object the result will also be a Unicode object.
1063
1070
 
1064
 
   Availability: Macintosh, Unix.
 
1071
   Availability: Unix.
1065
1072
 
1066
1073
 
1067
1074
.. function:: remove(path)
1071
1078
   :func:`unlink` function documented below.  On Windows, attempting to remove a
1072
1079
   file that is in use causes an exception to be raised; on Unix, the directory
1073
1080
   entry is removed but the storage allocated to the file is not made available
1074
 
   until the original file is no longer in use. Availability: Macintosh, Unix,
 
1081
   until the original file is no longer in use. Availability: Unix,
1075
1082
   Windows.
1076
1083
 
1077
1084
 
1100
1107
   the renaming will be an atomic operation (this is a POSIX requirement).  On
1101
1108
   Windows, if *dst* already exists, :exc:`OSError` will be raised even if it is a
1102
1109
   file; there may be no way to implement an atomic rename when *dst* names an
1103
 
   existing file. Availability: Macintosh, Unix, Windows.
 
1110
   existing file. Availability: Unix, Windows.
1104
1111
 
1105
1112
 
1106
1113
.. function:: renames(old, new)
1120
1127
 
1121
1128
.. function:: rmdir(path)
1122
1129
 
1123
 
   Remove the directory *path*. Availability: Macintosh, Unix, Windows.
 
1130
   Remove the directory *path*. Availability: Unix, Windows.
1124
1131
 
1125
1132
 
1126
1133
.. function:: stat(path)
1184
1191
      :attr:`st_mtime` has 2-second resolution, and :attr:`st_atime` has only 1-day
1185
1192
      resolution.  See your operating system documentation for details.
1186
1193
 
1187
 
   Availability: Macintosh, Unix, Windows.
 
1194
   Availability: Unix, Windows.
1188
1195
 
1189
1196
   .. versionchanged:: 2.2
1190
1197
      Added access to values as attributes of the returned object.
1264
1271
      Use of :func:`tempnam` is vulnerable to symlink attacks; consider using
1265
1272
      :func:`tmpfile` (section :ref:`os-newstreams`) instead.
1266
1273
 
1267
 
   Availability: Macintosh, Unix, Windows.
 
1274
   Availability: Unix, Windows.
1268
1275
 
1269
1276
 
1270
1277
.. function:: tmpnam()
1296
1303
.. function:: unlink(path)
1297
1304
 
1298
1305
   Remove the file *path*.  This is the same function as :func:`remove`; the
1299
 
   :func:`unlink` name is its traditional Unix name. Availability: Macintosh, Unix,
 
1306
   :func:`unlink` name is its traditional Unix name. Availability: Unix,
1300
1307
   Windows.
1301
1308
 
1302
1309
 
1303
1310
.. function:: utime(path, times)
1304
1311
 
1305
 
   Set the access and modified times of the file specified by *path*. If *times* is
1306
 
   ``None``, then the file's access and modified times are set to the current time.
1307
 
   Otherwise, *times* must be a 2-tuple of numbers, of the form ``(atime, mtime)``
1308
 
   which is used to set the access and modified times, respectively. Whether a
1309
 
   directory can be given for *path* depends on whether the operating system
1310
 
   implements directories as files (for example, Windows does not).  Note that the
1311
 
   exact times you set here may not be returned by a subsequent :func:`stat` call,
1312
 
   depending on the resolution with which your operating system records access and
1313
 
   modification times; see :func:`stat`.
 
1312
   Set the access and modified times of the file specified by *path*. If *times*
 
1313
   is ``None``, then the file's access and modified times are set to the current
 
1314
   time. (The effect is similar to running the Unix program :program:`touch` on
 
1315
   the path.)  Otherwise, *times* must be a 2-tuple of numbers, of the form
 
1316
   ``(atime, mtime)`` which is used to set the access and modified times,
 
1317
   respectively. Whether a directory can be given for *path* depends on whether
 
1318
   the operating system implements directories as files (for example, Windows
 
1319
   does not).  Note that the exact times you set here may not be returned by a
 
1320
   subsequent :func:`stat` call, depending on the resolution with which your
 
1321
   operating system records access and modification times; see :func:`stat`.
1314
1322
 
1315
1323
   .. versionchanged:: 2.0
1316
1324
      Added support for ``None`` for *times*.
1317
1325
 
1318
 
   Availability: Macintosh, Unix, Windows.
 
1326
   Availability: Unix, Windows.
1319
1327
 
1320
1328
 
1321
1329
.. function:: walk(top[, topdown=True [, onerror=None[, followlinks=False]]])
1428
1436
   behavior is to produce a core dump; on Windows, the process immediately returns
1429
1437
   an exit code of ``3``.  Be aware that programs which use :func:`signal.signal`
1430
1438
   to register a handler for :const:`SIGABRT` will behave differently.
1431
 
   Availability: Macintosh, Unix, Windows.
 
1439
   Availability: Unix, Windows.
1432
1440
 
1433
1441
 
1434
1442
.. function:: execl(path, arg0, arg1, ...)
1469
1477
   used to define the environment variables for the new process (these are used
1470
1478
   instead of the current process' environment); the functions :func:`execl`,
1471
1479
   :func:`execlp`, :func:`execv`, and :func:`execvp` all cause the new process to
1472
 
   inherit the environment of the current process. Availability: Macintosh, Unix,
 
1480
   inherit the environment of the current process. Availability: Unix,
1473
1481
   Windows.
1474
1482
 
1475
1483
 
1476
1484
.. function:: _exit(n)
1477
1485
 
1478
1486
   Exit to the system with status *n*, without calling cleanup handlers, flushing
1479
 
   stdio buffers, etc. Availability: Macintosh, Unix, Windows.
 
1487
   stdio buffers, etc. Availability: Unix, Windows.
1480
1488
 
1481
1489
   .. note::
1482
1490
 
1496
1504
 
1497
1505
.. data:: EX_OK
1498
1506
 
1499
 
   Exit code that means no error occurred. Availability: Macintosh, Unix.
 
1507
   Exit code that means no error occurred. Availability: Unix.
1500
1508
 
1501
1509
   .. versionadded:: 2.3
1502
1510
 
1504
1512
.. data:: EX_USAGE
1505
1513
 
1506
1514
   Exit code that means the command was used incorrectly, such as when the wrong
1507
 
   number of arguments are given. Availability: Macintosh, Unix.
 
1515
   number of arguments are given. Availability: Unix.
1508
1516
 
1509
1517
   .. versionadded:: 2.3
1510
1518
 
1511
1519
 
1512
1520
.. data:: EX_DATAERR
1513
1521
 
1514
 
   Exit code that means the input data was incorrect. Availability: Macintosh,
1515
 
   Unix.
 
1522
   Exit code that means the input data was incorrect. Availability: Unix.
1516
1523
 
1517
1524
   .. versionadded:: 2.3
1518
1525
 
1520
1527
.. data:: EX_NOINPUT
1521
1528
 
1522
1529
   Exit code that means an input file did not exist or was not readable.
1523
 
   Availability: Macintosh, Unix.
 
1530
   Availability: Unix.
1524
1531
 
1525
1532
   .. versionadded:: 2.3
1526
1533
 
1527
1534
 
1528
1535
.. data:: EX_NOUSER
1529
1536
 
1530
 
   Exit code that means a specified user did not exist. Availability: Macintosh,
1531
 
   Unix.
 
1537
   Exit code that means a specified user did not exist. Availability: Unix.
1532
1538
 
1533
1539
   .. versionadded:: 2.3
1534
1540
 
1535
1541
 
1536
1542
.. data:: EX_NOHOST
1537
1543
 
1538
 
   Exit code that means a specified host did not exist. Availability: Macintosh,
1539
 
   Unix.
 
1544
   Exit code that means a specified host did not exist. Availability: Unix.
1540
1545
 
1541
1546
   .. versionadded:: 2.3
1542
1547
 
1544
1549
.. data:: EX_UNAVAILABLE
1545
1550
 
1546
1551
   Exit code that means that a required service is unavailable. Availability:
1547
 
   Macintosh, Unix.
 
1552
   Unix.
1548
1553
 
1549
1554
   .. versionadded:: 2.3
1550
1555
 
1552
1557
.. data:: EX_SOFTWARE
1553
1558
 
1554
1559
   Exit code that means an internal software error was detected. Availability:
1555
 
   Macintosh, Unix.
 
1560
   Unix.
1556
1561
 
1557
1562
   .. versionadded:: 2.3
1558
1563
 
1560
1565
.. data:: EX_OSERR
1561
1566
 
1562
1567
   Exit code that means an operating system error was detected, such as the
1563
 
   inability to fork or create a pipe. Availability: Macintosh, Unix.
 
1568
   inability to fork or create a pipe. Availability: Unix.
1564
1569
 
1565
1570
   .. versionadded:: 2.3
1566
1571
 
1568
1573
.. data:: EX_OSFILE
1569
1574
 
1570
1575
   Exit code that means some system file did not exist, could not be opened, or had
1571
 
   some other kind of error. Availability: Macintosh, Unix.
 
1576
   some other kind of error. Availability: Unix.
1572
1577
 
1573
1578
   .. versionadded:: 2.3
1574
1579
 
1576
1581
.. data:: EX_CANTCREAT
1577
1582
 
1578
1583
   Exit code that means a user specified output file could not be created.
1579
 
   Availability: Macintosh, Unix.
 
1584
   Availability: Unix.
1580
1585
 
1581
1586
   .. versionadded:: 2.3
1582
1587
 
1584
1589
.. data:: EX_IOERR
1585
1590
 
1586
1591
   Exit code that means that an error occurred while doing I/O on some file.
1587
 
   Availability: Macintosh, Unix.
 
1592
   Availability: Unix.
1588
1593
 
1589
1594
   .. versionadded:: 2.3
1590
1595
 
1593
1598
 
1594
1599
   Exit code that means a temporary failure occurred.  This indicates something
1595
1600
   that may not really be an error, such as a network connection that couldn't be
1596
 
   made during a retryable operation. Availability: Macintosh, Unix.
 
1601
   made during a retryable operation. Availability: Unix.
1597
1602
 
1598
1603
   .. versionadded:: 2.3
1599
1604
 
1601
1606
.. data:: EX_PROTOCOL
1602
1607
 
1603
1608
   Exit code that means that a protocol exchange was illegal, invalid, or not
1604
 
   understood. Availability: Macintosh, Unix.
 
1609
   understood. Availability: Unix.
1605
1610
 
1606
1611
   .. versionadded:: 2.3
1607
1612
 
1609
1614
.. data:: EX_NOPERM
1610
1615
 
1611
1616
   Exit code that means that there were insufficient permissions to perform the
1612
 
   operation (but not intended for file system problems). Availability: Macintosh,
1613
 
   Unix.
 
1617
   operation (but not intended for file system problems). Availability: Unix.
1614
1618
 
1615
1619
   .. versionadded:: 2.3
1616
1620
 
1618
1622
.. data:: EX_CONFIG
1619
1623
 
1620
1624
   Exit code that means that some kind of configuration error occurred.
1621
 
   Availability: Macintosh, Unix.
 
1625
   Availability: Unix.
1622
1626
 
1623
1627
   .. versionadded:: 2.3
1624
1628
 
1626
1630
.. data:: EX_NOTFOUND
1627
1631
 
1628
1632
   Exit code that means something like "an entry was not found". Availability:
1629
 
   Macintosh, Unix.
 
1633
   Unix.
1630
1634
 
1631
1635
   .. versionadded:: 2.3
1632
1636
 
1635
1639
 
1636
1640
   Fork a child process.  Return ``0`` in the child and the child's process id in the
1637
1641
   parent.  If an error occurs :exc:`OSError` is raised.
1638
 
   Availability: Macintosh, Unix.
 
1642
   Availability: Unix.
1639
1643
 
1640
1644
 
1641
1645
.. function:: forkpty()
1645
1649
   new child's process id in the parent, and *fd* is the file descriptor of the
1646
1650
   master end of the pseudo-terminal.  For a more portable approach, use the
1647
1651
   :mod:`pty` module.  If an error occurs :exc:`OSError` is raised.
1648
 
   Availability: Macintosh, some flavors of Unix.
 
1652
   Availability: some flavors of Unix.
1649
1653
 
1650
1654
 
1651
1655
.. function:: kill(pid, sig)
1656
1660
 
1657
1661
   Send signal *sig* to the process *pid*.  Constants for the specific signals
1658
1662
   available on the host platform are defined in the :mod:`signal` module.
1659
 
   Availability: Macintosh, Unix.
 
1663
   Availability: Unix.
1660
1664
 
1661
1665
 
1662
1666
.. function:: killpg(pgid, sig)
1665
1669
      single: process; killing
1666
1670
      single: process; signalling
1667
1671
 
1668
 
   Send the signal *sig* to the process group *pgid*. Availability: Macintosh,
1669
 
   Unix.
 
1672
   Send the signal *sig* to the process group *pgid*. Availability: Unix.
1670
1673
 
1671
1674
   .. versionadded:: 2.3
1672
1675
 
1674
1677
.. function:: nice(increment)
1675
1678
 
1676
1679
   Add *increment* to the process's "niceness".  Return the new niceness.
1677
 
   Availability: Macintosh, Unix.
 
1680
   Availability: Unix.
1678
1681
 
1679
1682
 
1680
1683
.. function:: plock(op)
1681
1684
 
1682
1685
   Lock program segments into memory.  The value of *op* (defined in
1683
 
   ``<sys/lock.h>``) determines which segments are locked. Availability: Macintosh,
1684
 
   Unix.
 
1686
   ``<sys/lock.h>``) determines which segments are locked. Availability: Unix.
1685
1687
 
1686
1688
 
1687
1689
.. function:: popen(...)
1707
1709
 
1708
1710
   (Note that the :mod:`subprocess` module provides more powerful facilities for
1709
1711
   spawning new processes and retrieving their results; using that module is
1710
 
   preferable to using these functions.)
 
1712
   preferable to using these functions.  Check specially the *Replacing Older 
 
1713
   Functions with the subprocess Module* section in that documentation page.)
1711
1714
 
1712
1715
   If *mode* is :const:`P_NOWAIT`, this function returns the process id of the new
1713
1716
   process; if *mode* is :const:`P_WAIT`, returns the process's exit code if it
1762
1765
   Possible values for the *mode* parameter to the :func:`spawn\*` family of
1763
1766
   functions.  If either of these values is given, the :func:`spawn\*` functions
1764
1767
   will return as soon as the new process has been created, with the process id as
1765
 
   the return value. Availability: Macintosh, Unix, Windows.
 
1768
   the return value. Availability: Unix, Windows.
1766
1769
 
1767
1770
   .. versionadded:: 1.6
1768
1771
 
1773
1776
   functions.  If this is given as *mode*, the :func:`spawn\*` functions will not
1774
1777
   return until the new process has run to completion and will return the exit code
1775
1778
   of the process the run is successful, or ``-signal`` if a signal kills the
1776
 
   process. Availability: Macintosh, Unix, Windows.
 
1779
   process. Availability: Unix, Windows.
1777
1780
 
1778
1781
   .. versionadded:: 1.6
1779
1782
 
1838
1841
   the command run; on systems using a non-native shell, consult your shell
1839
1842
   documentation.
1840
1843
 
1841
 
   Availability: Macintosh, Unix, Windows.
 
1844
   Availability: Unix, Windows.
1842
1845
 
1843
1846
   The :mod:`subprocess` module provides more powerful facilities for spawning new
1844
1847
   processes and retrieving their results; using that module is preferable to using
1845
 
   this function.
 
1848
   this function.  Use the :mod:`subprocess` module.  Check especially the
 
1849
   :ref:`subprocess-replacements` section.
1846
1850
 
1847
1851
 
1848
1852
.. function:: times()
1851
1855
   other) times, in seconds.  The items are: user time, system time, children's
1852
1856
   user time, children's system time, and elapsed real time since a fixed point in
1853
1857
   the past, in that order.  See the Unix manual page :manpage:`times(2)` or the
1854
 
   corresponding Windows Platform API documentation. Availability: Macintosh, Unix,
 
1858
   corresponding Windows Platform API documentation. Availability: Unix,
1855
1859
   Windows.  On Windows, only the first two items are filled, the others are zero.
1856
1860
 
1857
1861
 
1861
1865
   and exit status indication: a 16-bit number, whose low byte is the signal number
1862
1866
   that killed the process, and whose high byte is the exit status (if the signal
1863
1867
   number is zero); the high bit of the low byte is set if a core file was
1864
 
   produced. Availability: Macintosh, Unix.
 
1868
   produced. Availability: Unix.
1865
1869
 
1866
1870
 
1867
1871
.. function:: waitpid(pid, options)
1880
1884
   ``-1``, status is requested for any process in the process group ``-pid`` (the
1881
1885
   absolute value of *pid*).
1882
1886
 
 
1887
   An :exc:`OSError` is raised with the value of errno when the syscall
 
1888
   returns -1.
 
1889
 
1883
1890
   On Windows: Wait for completion of a process given by process handle *pid*, and
1884
1891
   return a tuple containing *pid*, and its exit status shifted left by 8 bits
1885
1892
   (shifting makes cross-platform use of the function easier). A *pid* less than or
1916
1923
 
1917
1924
   The option for :func:`waitpid` to return immediately if no child process status
1918
1925
   is available immediately. The function returns ``(0, 0)`` in this case.
1919
 
   Availability: Macintosh, Unix.
 
1926
   Availability: Unix.
1920
1927
 
1921
1928
 
1922
1929
.. data:: WCONTINUED
1932
1939
 
1933
1940
   This option causes child processes to be reported if they have been stopped but
1934
1941
   their current state has not been reported since they were stopped. Availability:
1935
 
   Macintosh, Unix.
 
1942
   Unix.
1936
1943
 
1937
1944
   .. versionadded:: 2.3
1938
1945
 
1944
1951
.. function:: WCOREDUMP(status)
1945
1952
 
1946
1953
   Return ``True`` if a core dump was generated for the process, otherwise
1947
 
   return ``False``. Availability: Macintosh, Unix.
 
1954
   return ``False``. Availability: Unix.
1948
1955
 
1949
1956
   .. versionadded:: 2.3
1950
1957
 
1966
1973
.. function:: WIFSIGNALED(status)
1967
1974
 
1968
1975
   Return ``True`` if the process exited due to a signal, otherwise return
1969
 
   ``False``. Availability: Macintosh, Unix.
 
1976
   ``False``. Availability: Unix.
1970
1977
 
1971
1978
 
1972
1979
.. function:: WIFEXITED(status)
1973
1980
 
1974
1981
   Return ``True`` if the process exited using the :manpage:`exit(2)` system call,
1975
 
   otherwise return ``False``. Availability: Macintosh, Unix.
 
1982
   otherwise return ``False``. Availability: Unix.
1976
1983
 
1977
1984
 
1978
1985
.. function:: WEXITSTATUS(status)
1979
1986
 
1980
1987
   If ``WIFEXITED(status)`` is true, return the integer parameter to the
1981
1988
   :manpage:`exit(2)` system call.  Otherwise, the return value is meaningless.
1982
 
   Availability: Macintosh, Unix.
 
1989
   Availability: Unix.
1983
1990
 
1984
1991
 
1985
1992
.. function:: WSTOPSIG(status)
1986
1993
 
1987
 
   Return the signal which caused the process to stop. Availability: Macintosh,
1988
 
   Unix.
 
1994
   Return the signal which caused the process to stop. Availability: Unix.
1989
1995
 
1990
1996
 
1991
1997
.. function:: WTERMSIG(status)
1992
1998
 
1993
 
   Return the signal which caused the process to exit. Availability: Macintosh,
1994
 
   Unix.
 
1999
   Return the signal which caused the process to exit. Availability: Unix.
1995
2000
 
1996
2001
 
1997
2002
.. _os-path:
2009
2014
   The names known to the host operating system are given as the keys of the
2010
2015
   ``confstr_names`` dictionary.  For configuration variables not included in that
2011
2016
   mapping, passing an integer for *name* is also accepted. Availability:
2012
 
   Macintosh, Unix.
 
2017
   Unix.
2013
2018
 
2014
2019
   If the configuration value specified by *name* isn't defined, ``None`` is
2015
2020
   returned.
2024
2029
 
2025
2030
   Dictionary mapping names accepted by :func:`confstr` to the integer values
2026
2031
   defined for those names by the host operating system. This can be used to
2027
 
   determine the set of names known to the system. Availability: Macintosh, Unix.
 
2032
   determine the set of names known to the system. Availability: Unix.
2028
2033
 
2029
2034
 
2030
2035
.. function:: getloadavg()
2042
2047
   specified by *name* isn't defined, ``-1`` is returned.  The comments regarding
2043
2048
   the *name* parameter for :func:`confstr` apply here as well; the dictionary that
2044
2049
   provides information on the known names is given by ``sysconf_names``.
2045
 
   Availability: Macintosh, Unix.
 
2050
   Availability: Unix.
2046
2051
 
2047
2052
 
2048
2053
.. data:: sysconf_names
2049
2054
 
2050
2055
   Dictionary mapping names accepted by :func:`sysconf` to the integer values
2051
2056
   defined for those names by the host operating system. This can be used to
2052
 
   determine the set of names known to the system. Availability: Macintosh, Unix.
 
2057
   determine the set of names known to the system. Availability: Unix.
2053
2058
 
2054
2059
The following data values are used to support path manipulation operations.  These
2055
2060
are defined for all platforms.
2060
2065
.. data:: curdir
2061
2066
 
2062
2067
   The constant string used by the operating system to refer to the current
2063
 
   directory. For example: ``'.'`` for POSIX or ``':'`` for Mac OS 9. Also
2064
 
   available via :mod:`os.path`.
 
2068
   directory. This is ``'.'`` for Windows and POSIX. Also available via
 
2069
   :mod:`os.path`.
2065
2070
 
2066
2071
 
2067
2072
.. data:: pardir
2068
2073
 
2069
2074
   The constant string used by the operating system to refer to the parent
2070
 
   directory. For example: ``'..'`` for POSIX or ``'::'`` for Mac OS 9. Also
2071
 
   available via :mod:`os.path`.
 
2075
   directory. This is ``'..'`` for Windows and POSIX. Also available via
 
2076
   :mod:`os.path`.
2072
2077
 
2073
2078
 
2074
2079
.. data:: sep
2075
2080
 
2076
 
   The character used by the operating system to separate pathname components, for
2077
 
   example, ``'/'`` for POSIX or ``':'`` for Mac OS 9.  Note that knowing this is
2078
 
   not sufficient to be able to parse or concatenate pathnames --- use
 
2081
   The character used by the operating system to separate pathname components.
 
2082
   This is ``'/'`` for POSIX and ``'\\'`` for Windows.  Note that knowing this
 
2083
   is not sufficient to be able to parse or concatenate pathnames --- use
2079
2084
   :func:`os.path.split` and :func:`os.path.join` --- but it is occasionally
2080
2085
   useful. Also available via :mod:`os.path`.
2081
2086
 
2112
2117
.. data:: linesep
2113
2118
 
2114
2119
   The string used to separate (or, rather, terminate) lines on the current
2115
 
   platform.  This may be a single character, such as  ``'\n'`` for POSIX or
2116
 
   ``'\r'`` for Mac OS, or multiple  characters, for example, ``'\r\n'`` for
2117
 
   Windows. Do not use *os.linesep* as a line terminator when writing files  opened
2118
 
   in text mode (the default); use a single ``'\n'`` instead,  on all platforms.
 
2120
   platform.  This may be a single character, such as ``'\n'`` for POSIX, or
 
2121
   multiple characters, for example, ``'\r\n'`` for Windows. Do not use
 
2122
   *os.linesep* as a line terminator when writing files opened in text mode (the
 
2123
   default); use a single ``'\n'`` instead, on all platforms.
2119
2124
 
2120
2125
 
2121
2126
.. data:: devnull
2122
2127
 
2123
 
   The file path of the null device. For example: ``'/dev/null'`` for POSIX or
2124
 
   ``'Dev:Nul'`` for Mac OS 9. Also available via :mod:`os.path`.
 
2128
   The file path of the null device. For example: ``'/dev/null'`` for POSIX.
 
2129
   Also available via :mod:`os.path`.
2125
2130
 
2126
2131
   .. versionadded:: 2.4
2127
2132