pipe

Is it possible to prevent application from hanging when both stdin and stdout are connected to named pipes?

孤者浪人 提交于 2020-05-13 21:00:32
问题 Consider the following simple C program, which I will compile to a program called "A": #include <stdio.h> int main(int argc, char** argv){ putchar('C'); putchar('\n'); } Now, consider the following bash script: #!/bin/bash mkfifo Output1.pipe mkfifo Output2.pipe stdbuf -i0 -o0 -e0 ./A > Output1.pipe & stdbuf -i0 -o0 -e0 ./A > Output2.pipe & cat Output1.pipe cat Output2.pipe The output of this script is C\nC . So far everything is fine. Now let's consider the following modification the bash

Piping Text To An External Program Appends A Trailing Newline

戏子无情 提交于 2020-05-11 06:29:05
问题 I have been comparing hash values between multiple systems and was surprised to find that PowerShells hash values are different than that of other terminals. Linux terminals (CygWin, Bash for Windows, etc.) and Windows Command Prompt are all showing the same hash where as PowerShell is showing a different hash value. This was tested using SHA256 but found the same issue when using other algorithms like md5. Encoding Update: Tried changing the PShell encoding but it did not have any effect on

Piping Text To An External Program Appends A Trailing Newline

馋奶兔 提交于 2020-05-11 06:29:05
问题 I have been comparing hash values between multiple systems and was surprised to find that PowerShells hash values are different than that of other terminals. Linux terminals (CygWin, Bash for Windows, etc.) and Windows Command Prompt are all showing the same hash where as PowerShell is showing a different hash value. This was tested using SHA256 but found the same issue when using other algorithms like md5. Encoding Update: Tried changing the PShell encoding but it did not have any effect on

How to directly invoke the system shell in Go (golang)?

我们两清 提交于 2020-05-09 17:28:40
问题 As per the golang documentation, go does not make a call to the system's shell when you are using exec.Command(). From the golang.org documentation on the "os/exec" package: Unlike the "system" library call from C and other languages, the os/exec package intentionally does not invoke the system shell and does not expand any glob patterns or handle other expansions, pipelines, or redirections typically done by shells. This presents a problem. Because of this design choice you cannot use piping

How to directly invoke the system shell in Go (golang)?

给你一囗甜甜゛ 提交于 2020-05-09 17:27:17
问题 As per the golang documentation, go does not make a call to the system's shell when you are using exec.Command(). From the golang.org documentation on the "os/exec" package: Unlike the "system" library call from C and other languages, the os/exec package intentionally does not invoke the system shell and does not expand any glob patterns or handle other expansions, pipelines, or redirections typically done by shells. This presents a problem. Because of this design choice you cannot use piping

How to print both execl in fork using pipe (two children)?

拜拜、爱过 提交于 2020-05-09 10:27:25
问题 I am trying using pipe() to execute ls | wc . The fork part successfully prints as I expected (first parent --> first child --> second parent --> second child), but it does not print out the second child's part ( wc ). I put the exactly same codes for both first child and second child, and I have no idea how I can successfully edit the codes. The entire codes are written below: #include<stdio.h> #include<stdlib.h> #include<unistd.h> #include<sys/types.h> #include<string.h> #include<sys/wait.h

Sending pipe arguments to a C# application

前提是你 提交于 2020-05-08 12:16:52
问题 I need to build an simple console application that accepts a pipe as input. We are running Windows Server 2012. The data is coming from another application that is going to "pipe" the input to this application. I have an understanding of pipes from a Linux perspective but do not understand them well from a Windows perspective. My best guess is that I need to send input to my application like this: C:\app.exe < test.txt When using the '<' character my current understanding is that it converts

bash built-in command “select” not work via pipe in shell script

时光总嘲笑我的痴心妄想 提交于 2020-04-21 08:13:16
问题 I wrote a shell script using bash built-in command select to create selection menu. It works well when invoking by bash directly. But if I use pipe | such as cat script.sh | bash , the select function will not work. For example, code snippet shows #!/usr/bin/env bash arr=("Red Hat" "SUSE" "Debian") PS3="Choose distribution:" result=${result:-} select item in "${arr[@]}"; do result="${item}" [[ -n "${result}" ]] && break done echo "Result is ${result}" unset PS3 Directly using bash script.sh ,

bash built-in command “select” not work via pipe in shell script

瘦欲@ 提交于 2020-04-21 08:11:22
问题 I wrote a shell script using bash built-in command select to create selection menu. It works well when invoking by bash directly. But if I use pipe | such as cat script.sh | bash , the select function will not work. For example, code snippet shows #!/usr/bin/env bash arr=("Red Hat" "SUSE" "Debian") PS3="Choose distribution:" result=${result:-} select item in "${arr[@]}"; do result="${item}" [[ -n "${result}" ]] && break done echo "Result is ${result}" unset PS3 Directly using bash script.sh ,

Python Subprocess: how/when do they close file?

独自空忆成欢 提交于 2020-04-18 04:01:42
问题 I wonder why subprocesses keep so many files open. I have an example in which some files seem to remain open forever (after the subprocess finishes and even after the program crashes). Consider the following code: import aiofiles import tempfile async def main(): return [await fds_test(i) for i in range(2000)] async def fds_test(index): print(f"Writing {index}") handle, temp_filename = tempfile.mkstemp(suffix='.dat', text=True) async with aiofiles.open(temp_filename, mode='w') as fp: await fp