attempt to get a chunk of data to write to our child process's
        stdin, then write it.  the return value answers the questions "are we
        done writing forever?"
503441
def write(self):
        

        # get_chunk may sometimes return bytes, and sometimes return strings
        # because of the nature of the different types of STDIN objects we
        # support
        try:
            chunk = self.get_chunk()
            if chunk is None:
                raise DoneReadingForever

        except DoneReadingForever:
            self.log.debug("done reading")

            if self.tty_in:
                # EOF time
                try:
                    char = termios.tcgetattr(self.stream)[6][termios.VEOF]
                except:
                    char = chr(4).encode()

                # normally, one EOF should be enough to signal to an program
                # that is read()ing, to return 0 and be on your way.  however,
                # some programs are misbehaved, like python3.1 and python3.2.
                # they don't stop reading sometimes after read() returns 0.
                # this can be demonstrated with the following program:
                #
                # import sys
                # sys.stdout.write(sys.stdin.read())
                #
                # then type 'a' followed by ctrl-d 3 times.  in python
                # 2.6,2.7,3.3,3.4,3.5,3.6, it only takes 2 ctrl-d to terminate.
                # however, in python 3.1 and 3.2, it takes all 3.
                #
                # so here we send an extra EOF along, just in case.  i don't
                # believe it can hurt anything
                os.write(self.stream, char)
                os.write(self.stream, char)

            return True

        except NotYetReadyToRead:
            self.log.debug("received no data")
            return False

        # if we're not bytes, make us bytes
        if IS_PY3 and hasattr(chunk, "encode"):
            chunk = chunk.encode(self.encoding)

        for proc_chunk in self.stream_bufferer.process(chunk):
            self.log.debug("got chunk size %d: %r", len(proc_chunk),
                    proc_chunk[:30])

            self.log.debug("writing chunk to process")
            try:
                os.write(self.stream, proc_chunk)
            except OSError:
                self.log.debug("OSError writing stdin chunk")
                return True
475989
def write(self, data):
        

        try:
            ret = self._wrap_socket_library_call(
                lambda: SSL_write(self._ssl.value, data), ERR_WRITE_TIMEOUT)
        except openssl_error() as err:
            if err.ssl_error == SSL_ERROR_SYSCALL and err.result == -1:
                raise_ssl_error(ERR_PORT_UNREACHABLE, err)
            raise
        if ret:
            self._handshake_done = True
        return ret
995773
def _writer(self):
        
        while not self.closed:
            try:
                sock, data = self._write_queue.get(timeout=0.1)
                self._write_queue.task_done()
                sock.send(data)
            except Empty:
                pass  # nothing to write after timeout
            except socket.error as err:
                if err.errno == errno.EBADF:
                    self._clean_dead_sessions()
468545
async def write(self, chunk: bytes,
                    *, drain: bool=True, LIMIT: int=0x10000) -> None:
        
        if self._on_chunk_sent is not None:
            await self._on_chunk_sent(chunk)

        if self._compress is not None:
            chunk = self._compress.compress(chunk)
            if not chunk:
                return

        if self.length is not None:
            chunk_len = len(chunk)
            if self.length >= chunk_len:
                self.length = self.length - chunk_len
            else:
                chunk = chunk[:self.length]
                self.length = 0
                if not chunk:
                    return

        if chunk:
            if self.chunked:
                chunk_len_pre = ('%x\r\n' % len(chunk)).encode('ascii')
                chunk = chunk_len_pre + chunk + b'\r\n'

            self._write(chunk)

            if self.buffer_size > LIMIT and drain:
                self.buffer_size = 0
                await self.drain()
1137668
def _writen(fd, data):
    """"""
    while data:
        n = os.write(fd, data)
        data = data[n:]
191794
function end () {
          console.log('\n=== REG DUMP ===\n' + cpu.regdump().join('\n'))
          if (options.memDump) console.log('\n\n=== MEM DUMP ===\n' + cpu.memdump(0, 65535).join('\n'))
          process.exit() // workaround for stdin event listener hanging
        }
829177
function _write (chunk, encoding, callback) {
  /* istanbul ignore else */
  if (Array.isArray(this.options.input.buffer)) {
    /* istanbul ignore else */
    if (is.buffer(chunk)) {
      if (this.options.input.buffer.length === 0) {
        const that = this;
        this.on('finish', function () {
          that.streamInFinished = true;
        });
      }
      this.options.input.buffer.push(chunk);
      callback();
    } else {
      callback(new Error('Non-Buffer data on Writable Stream'));
    }
  } else {
    callback(new Error('Unexpected data on Writable Stream'));
  }
}
963565
def streamWrite(self, size):
        
        size = int(size)
        if size == 0:
            self._close()
            return

        self._sendResult(dict(message="writing...", stream=True, size=size))
        data = sys.stdin.read(size)
        self.stream.write(data)
393996
def write_eof(self):
        
        self._check_writable()
        self._transport._can_write.wait()
        self._transport.write_eof()
659461
int receive(byte[] b, int offset, int length) throws IOException, InterruptedException {

    synchronized (readLock) {
      if (remaining > 0) {
        int bytesToRead = Math.min(remaining, length);
        int result = stdin.read(b, offset, bytesToRead);
        remaining -= result;
        return result;
      }
      if (eof) {
        return -1;
      }
    }

    // make client know we want more data!
    sendSendInput();

    synchronized (readLock) {
      if (remaining == 0 && !eof) {
        readLock.wait();
      }

      // at this point we should have data so call itself recursively to utilize
      // reentrant lock
      return receive(b, offset, length);
    }
  }
4653
def _WritePartial(self, data):
    """"""

    chunk = self.offset // self.chunksize
    chunk_offset = self.offset % self.chunksize
    data = utils.SmartStr(data)

    available_to_write = min(len(data), self.chunksize - chunk_offset)

    fd = self._GetChunkForWriting(chunk)
    fd.seek(chunk_offset)

    fd.write(data[:available_to_write])
    self.offset += available_to_write

    return data[available_to_write:]
998784
def write (self, s):
        
        if isinstance(s, bytes):
            s = self._decode(s)
        for c in s:
            self.process(c)
171669
def Run(self):
    
    if not self.executable:
      logging.error('Could not locate "%s"' % self.long_name)
      return 0

    finfo = os.stat(self.executable)
    self.date = time.localtime(finfo[stat.ST_MTIME])

    logging.info('Running: %s %s </dev/null 2>&1'
                 % (self.executable, FLAGS.help_flag))
    # --help output is often routed to stderr, so we combine with stdout.
    # Re-direct stdin to /dev/null to encourage programs that
    # don't understand --help to exit.
    (child_stdin, child_stdout_and_stderr) = os.popen4(
      [self.executable, FLAGS.help_flag])
    child_stdin.close()       # '</dev/null'
    self.output = child_stdout_and_stderr.readlines()
    child_stdout_and_stderr.close()
    if len(self.output) < _MIN_VALID_USAGE_MSG:
      logging.error('Error: "%s %s" returned only %d lines: %s'
                    % (self.name, FLAGS.help_flag,
                       len(self.output), self.output))
      return 0
    return 1
825242
def page_stdout
      return unless $stdout.tty?

      read, write = IO.pipe

      if Kernel.fork
        # Parent process, become pager
        $stdin.reopen(read)
        read.close
        write.close

        # Don't page if the input is short enough
        ENV['LESS'] = 'FSRX'

        # Wait until we have input before we start the pager
        Kernel.select [STDIN]

        pager = ENV['PAGER'] || 'less -isr'
        pager = 'cat' if pager.empty?

        exec pager rescue exec "/bin/sh", "-c", pager
      else
        # Child process
        $stdout.reopen(write)
        $stderr.reopen(write) if $stderr.tty?
        read.close
        write.close
      end
    end
1013322
async def write(self, data):
        
        self.writer.write((bytes([ord(data)])))
        await self.writer.drain()
1025932
async function writeChunk(){
        if (chunks.length > 0){
            // get first element
            const l = chunks.shift();

            // increment size counter
            currentUploadSize += l.length;

            // write first element to file
            try{
                await _virtualTerminal.executeCommand('__nmtwrite("' + l + '")');
            }catch(e){
                _logger.debug(e);
                throw new Error('cannot write chunk to remote file');
            }

            // run progress callback
            progressCb.apply(progressCb, [currentUploadSize, absoluteFilesize]);

            // write next
            await writeChunk();

        }else{
            // ensure that the progress callback is called, even for empty files
            progressCb.apply(progressCb, [currentUploadSize, absoluteFilesize]);

            // send file close command
            try{
                await _virtualTerminal.executeCommand(_luaCommandBuilder.command.fileCloseFlush);
            }catch(e){
                _logger.debug(e);
                throw new Error('cannot flush/close remote file');
            }
        }
    }
66549
def _Write(self, data, length, progress_callback=None):
        """"""
        if progress_callback:
            progress = self._HandleProgress(length, progress_callback)
            next(progress)
        while length:
            tmp = data.read(self.chunk_kb * 1024)
            length -= len(tmp)
            self.usb.BulkWrite(tmp)

            if progress_callback and progress:
                progress.send(len(tmp))