stdin

Close the stdin of boost::process child

怎甘沉沦 提交于 2020-06-27 23:22:30
问题 I'm trying to call a process with a string to its stdin, with Boost-1.64.0. The current code is : bp::opstream inStream ; bp::ipstream outStream; bp::ipstream errStream; bp::child child( command, // the command line bp::shell, bp::std_out > outStream, bp::std_err > errStream, bp::std_in < inStream); // read the outStream/errStream in threads child.wait(); The problem is that the child executable is waiting for its stdin EOF. Here child.wait() is hanging indefinitely… I tried to used asio:

how to make StdIn.isEmpty() return true?

左心房为你撑大大i 提交于 2020-06-26 06:39:38
问题 I am using the StdIn.isEmpty() method from the Princeton libraries provided in the Algorithms Coursera algorithms course but am confused as to how it works. I have the statement while (!StdIn.isEmpty()) with some code enclosed that reads user input but I can't seem to break out of the loop. By my understanding if I hit enter without typing in any text that should mean that standard input is empty and the while loop should be broken. I looked up the code for isEmpty but it did not clarify

Argparse and ArgumentDefaultsHelpFormatter. Formatting of default values when sys.stdin/stdout are selected as default

空扰寡人 提交于 2020-06-25 09:14:02
问题 I am interested in using the ArgumentDefaultsHelpFormatter class formatter of argparse (my program has several sub-commands). By default, the input and output arguments are set to sys.stdin and sys.stdout respectively. However, the formatting for these two arguments may be a little bit confusing for users (e.g (default: ', mode 'r' at 0x10028e0c0>). Is there a way to specifically and easily change the output format for these two arguments to get something like 'default: STDIN' or 'default:

Argparse and ArgumentDefaultsHelpFormatter. Formatting of default values when sys.stdin/stdout are selected as default

廉价感情. 提交于 2020-06-25 09:13:39
问题 I am interested in using the ArgumentDefaultsHelpFormatter class formatter of argparse (my program has several sub-commands). By default, the input and output arguments are set to sys.stdin and sys.stdout respectively. However, the formatting for these two arguments may be a little bit confusing for users (e.g (default: ', mode 'r' at 0x10028e0c0>). Is there a way to specifically and easily change the output format for these two arguments to get something like 'default: STDIN' or 'default:

Continuous communication between parent and child subprocess in Python (Windows)?

懵懂的女人 提交于 2020-05-29 06:54:30
问题 I have this script: import subprocess p = subprocess.Popen(["myProgram.exe"], stdin=subprocess.PIPE, stdout=subprocess.PIPE) while True: out, _ = p.communicate(input().encode()) print(out.decode()) which works fine until the second input where I get: ValueError: Cannot send input after starting communication Is there a way to have multiple messages sent between the parent and child process in Windows ? [EDIT] I don't have access to the source code of myProgram.exe It is an interactive command

How to enable atom.io to read STDIN?

ぃ、小莉子 提交于 2020-04-13 10:35:13
问题 Is there an easy way to pipe content to the editor atom? For example: echo "Content." | atom Unfortunately atom does not get the content. The current version of gedit has the parameter - to enable reading of STDIN: echo "Content." | gedit - I could not find a similar option in the atom-help ( atom -h ) 回答1: Thank you for asking about this! I just now bumped into the same issue. Is there an easy way to pipe content to the editor atom? The current atom command-line interface (CLI) will not open

How to read input from STDIN in x86_64 assembly?

倾然丶 夕夏残阳落幕 提交于 2020-04-07 18:51:09
问题 I am trying to learn x86_64 assembly and I was trying standard input output today and stumbled upon this post Learning assembly - echo program name How would I do the same for reading the input from STDIN (using SYSCALL instruction)? Especially if I know that the input will always be an integer and I want to read it to a register? EDIT: @Daniel Kozar's answer below helped me understand how STDIN and STDOUT stuff work with the SYSCALL instruction on Linux. I attempted to write a small program,

How to read input from STDIN in x86_64 assembly?

落花浮王杯 提交于 2020-04-07 18:48:24
问题 I am trying to learn x86_64 assembly and I was trying standard input output today and stumbled upon this post Learning assembly - echo program name How would I do the same for reading the input from STDIN (using SYSCALL instruction)? Especially if I know that the input will always be an integer and I want to read it to a register? EDIT: @Daniel Kozar's answer below helped me understand how STDIN and STDOUT stuff work with the SYSCALL instruction on Linux. I attempted to write a small program,

Making stdin writable in a safe and portable way

*爱你&永不变心* 提交于 2020-03-06 09:28:08
问题 I was trying to run two programs. Case 1 #include <stdio.h> #include <stdlib.h> #include <unistd.h> int main() { int n; int k = 10; int ret_val = 0; ret_val = write (0, &k, sizeof(int)); if (-1 == ret_val) { printf ("Failed to write"); exit (EXIT_FAILURE); } scanf ("%d", &n); printf ("Integer read is %d \n", n); return 0; } Then I tried the next one. Case 2 #include <stdio.h> #include <stdlib.h> #include <unistd.h> #include <sys/types.h> #include <sys/stat.h> #include <fcntl.h> int main() {

How to convert string to unsigned long in C++? [duplicate]

。_饼干妹妹 提交于 2020-03-03 13:06:34
问题 This question already has answers here : C++ convert hex string to signed integer (8 answers) Closed 6 years ago . I need help in programming. The program has to accept a string that will eventually be turned to unsigned long. But here's the catch, there must be an error catcher that when you enter combination of hex and symbols like a!!!!!! will produce an error and the unsigned long variable must be able to accept and store the input greater that 4294967295 which is FFFFFFFF . I've tried