1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 18:47:34 +00:00

Add /dev/{stdin,stdout,stderr} as symlinks to /proc/self/fd/{0,1,2}

Also change /bin/cat to open /dev/stdin if no arguments are provided.
This commit is contained in:
Andreas Kling 2019-02-03 12:38:03 +01:00
parent 5e9ba2ac84
commit 31f44481f3
2 changed files with 6 additions and 6 deletions

View file

@ -8,13 +8,10 @@
int main(int argc, char** argv)
{
if (argc != 2) {
printf("usage: cat <file>\n");
return 1;
}
int fd = open(argv[1], O_RDONLY);
const char* input_file = argc > 1 ? argv[1] : "/dev/stdin";
int fd = open(input_file, O_RDONLY);
if (fd == -1) {
printf("failed to open %s: %s\n", argv[1], strerror(errno));
printf("failed to open %s: %s\n", input_file, strerror(errno));
return 1;
}
for (;;) {