Changeset 15230 for trunk/source/level-1


Ignore:
Timestamp:
Mar 4, 2012, 3:01:55 PM (7 years ago)
Author:
gb
Message:

(SAME-FD-P a b) returns true if it can tell that file descriptors
(file handles on Windows) a and b refer to the same underlying file
(socket, pipe, tty.)

Make *ERROR-OUTPUT* a synonym to CCL::*STDERR* if *batch-flag* or if
file descriptors 1 and 2 (or the Windows equivalents) don't refer
to the same file (handy for those who run interactively with whatever
line noise is required to redirect fd 2 ...)

Location:
trunk/source/level-1
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/source/level-1/l1-boot-2.lisp

    r15169 r15230  
    176176        (setq *standard-input* (make-synonym-stream '*terminal-io*)
    177177              *standard-output* (make-synonym-stream '*terminal-io*))))
    178     (setq *error-output* (if *batch-flag*
     178    (setq *error-output* (if (or *batch-flag*
     179                                 (not (same-fd-p (stream-device *stderr* :output)
     180                                                 (stream-device *stdout* :output))))
    179181                           (make-synonym-stream '*stderr*)
    180182                           (make-synonym-stream '*terminal-io*)))
  • trunk/source/level-1/linux-files.lisp

    r15146 r15230  
    21852185;;(assert (= (logcount *host-page-size*) 1))
    21862186
     2187
     2188(defun same-fd-p (a b)
     2189  (or (eql a b)
     2190      #-windows-target
     2191      (let* ((a-stat (multiple-value-list (%fstat a)))
     2192             (b-stat (multiple-value-list (%fstat b))))
     2193        (declare (dynamic-extent a-stat b-stat))
     2194        (and (car a-stat) (car b-stat)
     2195             (eql (nth 9 a-stat)
     2196                  (nth 9 b-stat))
     2197             (eql (nth 4 a-stat)
     2198                  (nth 4 b-stat))))
     2199      #+windows-target
     2200      (rlet ((a-info #>BY_HANDLE_FILE_INFORMATION)
     2201             (b-info #>BY_HANDLE_FILE_INFORMATION))
     2202        (unless (or (eql 0 (#_GetFileInformationByHandle (%int-to-ptr a) a-info))
     2203                    (eql 0 (#_GetFileInformationByHandle (%int-to-ptr b) b-info)))
     2204          (and (eql (pref a-info #>BY_HANDLE_FILE_INFORMATION.dwVolumeSerialNumber)
     2205                    (pref b-info #>BY_HANDLE_FILE_INFORMATION.dwVolumeSerialNumber))
     2206               (eql (pref a-info #>BY_HANDLE_FILE_INFORMATION.nFileIndexHigh)
     2207                    (pref b-info #>BY_HANDLE_FILE_INFORMATION.nFileIndexHigh))
     2208               (eql (pref a-info #>BY_HANDLE_FILE_INFORMATION.nFileIndexLow)
     2209                    (pref b-info #>BY_HANDLE_FILE_INFORMATION.nFileIndexLow)))))))
     2210
     2211 
    21872212(defun get-universal-time ()
    21882213  "Return a single integer for the current time of
Note: See TracChangeset for help on using the changeset viewer.