     let terminalType:TerminalController.TerminalType = try mode.withCString {
         (modeCString: UnsafePointer<CChar>) -> TerminalController.TerminalType in
         
-        let filePointer: FILEPointer! = fdopen(fileDescriptor, modeCString)
-        let s = try LocalFileOutputByteStream(filePointer: filePointer)
-        return TerminalController.terminalType(s)
+        let filePointer: FILEPointer! = fdopen(stdOutFileDescriptor, modeCString)
+        let stream = try LocalFileOutputByteStream(filePointer: filePointer)
+        // TerminalController.terminalType() use isatty() inside.
+        return TerminalController.terminalType(stream)
     }
     
     return terminalType

    // FILEPointer(aka UnsafeMutablePointer<FILE>)はCのFILE*と同じと仮定
    // fdopenで fileDescriptorから filePointerを作り、
    // FILEPointerからLocalFileOutputByteStream を作り、terminalTypeを取得
    let fileDescriptor: Int32 = {
        if #available(macOS 11,*) {
            return FileDescriptor.standardOutput.rawValue as Int32
        } else {

        silence = silenceModeCommandLineFlag
        
        colored = {
            // commandline
            if noColorCommandLineFlag {
                return false
            }
