File: popen2.g

package info (click to toggle)
gap-io 4.7.0%2Bds-2
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 772 kB
  • sloc: xml: 2,871; ansic: 2,685; makefile: 36; sh: 6
file content (15 lines) | stat: -rw-r--r-- 487 bytes parent folder | download | duplicates (7)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
# Pipes some megabytes through /bin/cat:
LoadPackage("io");
s := "Max";
for i in [1..25] do Append(s,s); od;
Print("Have string of length ",Length(s),".\n");
p := IO_Popen2("/bin/cat",[]);
IO_SendStringBackground(p.stdin,s);
# We want that /bin/cat terminates after the child has sent everything:
IO_Close(p.stdin);
t := IO_ReadUntilEOF(p.stdout);
IO_Close(p.stdout);
Print("Have read string!\n");
if s <> t then
    Print("Alert: Received string not identical to original one!\n");
fi;