- if (arg_stdin) {
- log_info("Reading standard input...");
- r = add_source(s, STDIN_FILENO, "stdin");
+ STRV_FOREACH(file, arg_files) {
+ if (streq(*file, "-")) {
+ log_info("Reading standard input...");
+
+ fd = STDIN_FILENO;
+ output_name = "stdin";
+ } else {
+ log_info("Reading file %s...", *file);
+
+ fd = open(*file, O_RDONLY|O_CLOEXEC|O_NOCTTY|O_NONBLOCK);
+ if (fd < 0) {
+ log_error("Failed to open %s: %m", *file);
+ return -errno;
+ }
+ output_name = *file;
+ }
+
+ r = add_source(s, fd, output_name);