Sample Header Ad - 728x90

Unix & Linux Stack Exchange

Q&A for users of Linux, FreeBSD and other Unix-like operating systems

Latest Questions

1 votes
1 answers
104 views
If fprinting to stderr fails, which error code should a C program return?
Assume the following C snippet showing a piece of error handling: ```C #include #include … int main(int argc, char argv*[]) { int retval=0; … if(3!=argc) { /* wrong number of arguments */ retval |= EX_USAGE; const int fprintf_retval = fprintf(stderr, "Bad syntax.\n"); if (0>=fprintf_retval) retval |...
Assume the following C snippet showing a piece of error handling:
#include 
#include 
…
int main(int argc, char argv*[]) {
  int retval=0;
  …
  if(3!=argc) { /* wrong number of arguments */
    retval |= EX_USAGE;
    const int fprintf_retval = fprintf(stderr, "Bad syntax.\n");
    if (0>=fprintf_retval) retval |= … Hmm …  ;
  }
  …
  return retval;
}
Which error constant from sysexits.h should be placed instead of “… Hmm …”? We can say EX_OSERR (a failure to print an error message shows that something is off, though not necessarily deep in the operating system), or EX_IOERR (it's an output error, though not necessarily into a file), or EX_SOFTWARE (fairly general, but the reason for a failure to print an error typically lies outside the C program, and the error might relate to the operating system). Based only on the comments in sysexits.h, neither of the three constants fits perfectly. So what's the convention? EDIT: In the scope of this question, we assume that the programmer does want to discern between certain kinds of errors via the exit code, and that more than one error can occur.
user743115 (1 rep)
Jul 24, 2025, 12:48 AM • Last activity: Jul 24, 2025, 09:15 AM
9 votes
4 answers
32715 views
Write to stderr
I'm using [stderred][1] to color all output streamed to stderr red. It's working fine. But when I write my own bash script and throw an error with `echo 'error' 1>&2`, it doesn't color the output in red. I reckon this is, because the command simply redirects the output to wherever the stderr file de...
I'm using stderred to color all output streamed to stderr red. It's working fine. But when I write my own bash script and throw an error with echo 'error' 1>&2, it doesn't color the output in red. I reckon this is, because the command simply redirects the output to wherever the stderr file descriptor points to, but doesn't properly mark the message as belonging to stderr. Is that so? How can I properly write to stderr in bash?
pfnuesel (6263 rep)
Oct 25, 2014, 05:28 PM • Last activity: Jul 21, 2025, 02:44 PM
2 votes
3 answers
4636 views
CSH and all output (with errors) to file
I need save all output from compilation to file. I have many errors `undefined reference` and I want see all of these errors. I try `makeall >& out`, but in file `out` aren't any of error `undefined reference`. I must use `csh` to run `makeall`.
I need save all output from compilation to file. I have many errors undefined reference and I want see all of these errors. I try makeall >& out, but in file out aren't any of error undefined reference. I must use csh to run makeall.
marcin (65 rep)
Mar 27, 2015, 10:32 AM • Last activity: Jun 30, 2025, 08:03 AM
12 votes
4 answers
20270 views
How to redirect stderr in a variable but keep stdout in the console
My goal is to call a command, get stderr in a variable, but keep stdout (and only stdout) on the screen. Yep, that's the opposite of what most people do :) For the moment, the best I have is : #!/bin/bash pull=$(sudo ./pull "${TAG}" 2>&1) pull_code=$? if [[ ! "${pull_code}" -eq 0 ]]; then error "[${...
My goal is to call a command, get stderr in a variable, but keep stdout (and only stdout) on the screen. Yep, that's the opposite of what most people do :) For the moment, the best I have is : #!/bin/bash pull=$(sudo ./pull "${TAG}" 2>&1) pull_code=$? if [[ ! "${pull_code}" -eq 0 ]]; then error "[${pull_code}] ${pull}" exit "${E_PULL_FAILED}" fi echo "${pull}" But this can only show the stdout in case of success, and after the command finish. I want to have stdout on live, is this possible ? **EDIT** Thanks to @sebasth, and with the help of https://unix.stackexchange.com/questions/430161/redirect-stderr-and-stdout-to-different-variables-without-temporary-files , I write this : #!/bin/bash { sudo ./pull "${TAG}" 2> /dev/fd/3 pull_code=$? if [[ ! "${pull_code}" -eq 0 ]]; then echo "[${pull_code}] $(cat<&3)" exit "${E_PULL_FAILED}" fi } 3<
Doubidou (223 rep)
Oct 9, 2018, 08:46 AM • Last activity: Jun 10, 2025, 06:30 PM
1 votes
0 answers
29 views
What is "NULL device *" warning on console
I am getting this message on the console of my AlmaLinux 9 host: [31178.107847] (NULL device *): port 1 already used(dev 6/1/4 stat 2 I've tried to google pieces of the message but getting no where. What is this message trying to tell me? It repeats every 10 seconds so I assume its important
I am getting this message on the console of my AlmaLinux 9 host: [31178.107847] (NULL device *): port 1 already used(dev 6/1/4 stat 2 I've tried to google pieces of the message but getting no where. What is this message trying to tell me? It repeats every 10 seconds so I assume its important
TSG (1983 rep)
Jun 4, 2025, 09:43 PM
10 votes
5 answers
1763 views
Recommended way for a Linux app to inform user of an exception
In this context, an 'exception' is an undesirable scenario, which could be: a code-level signal (like SIGSEGV), incorrect ways of launching an app (like launching a command-line app as a daemon) etc. For a command-line app, the way to report exceptions to the user is by outputting to stderr - no dou...
In this context, an 'exception' is an undesirable scenario, which could be: a code-level signal (like SIGSEGV), incorrect ways of launching an app (like launching a command-line app as a daemon) etc. For a command-line app, the way to report exceptions to the user is by outputting to stderr - no doubts here. For a GUI app using GTK, an error window displayed using GTK's [MessageDialog](https://docs.gtk.org/gtk3/class.MessageDialog.html) can be used. But what if the MessageDialog fails, either due to unstable state of the app (SIGSEGV or SIGBUS may not have any recovery) or the API itself failed... in that case, how can a GUI app inform the user? Finally, a daemon... A daemon needs to inform user either due to a code-level exception (signals) or an external exception - user could launch a command-line app as a daemon, which is not a desirable way of launch, since a command-line app would've exited after its task is completed, but a daemon is expected to run for a long time. The command-line app could detect it was launched as a daemon and inform the user that it was launched incorrectly, but output to stderr does nothing here... how can a command-line app launched as daemon inform user that it was launched incorrectly? The main question is, how can each of these apps communicate with the user in the above mentioned scenarios? What is Linux's recommendation? PS: I'm new to Linux and app development in Linux.
NightFuryLxD (201 rep)
May 24, 2025, 02:18 PM • Last activity: May 27, 2025, 10:38 AM
17 votes
1 answers
8354 views
`docker logs foo | less` isn't searchable or scrollable but `docker logs foo 2>&1 | less` is
Using either `docker logs foo | less` or `docker logs foo 2>&1 | less` produces readable text, but only with the stderr redirect can one scroll or type `/somepattern` and obtain matches. Without it, searching gives "Nothing to search (press RETURN)" and a column of `~`'s. Given that stderr and stdou...
Using either docker logs foo | less or docker logs foo 2>&1 | less produces readable text, but only with the stderr redirect can one scroll or type /somepattern and obtain matches. Without it, searching gives "Nothing to search (press RETURN)" and a column of ~'s. Given that stderr and stdout aren't the same, why does less show them the same until I start doing something in less? This may be some weird multi-window vim thing that I just don't understand. Thoughts?
MagicWindow (311 rep)
Mar 29, 2016, 09:01 PM • Last activity: May 23, 2025, 08:37 AM
4 votes
3 answers
3660 views
Redirect stdout of a Windows command line program under wine
I run a Windows command line program (that I can not make accessible) with wine. It apparently writes something to stdout and I'm trying to capture that output, but I can't redirect it. No matter if I redirect stdout or stderr to a file, the program output is still printed on the console and is not...
I run a Windows command line program (that I can not make accessible) with wine. It apparently writes something to stdout and I'm trying to capture that output, but I can't redirect it. No matter if I redirect stdout or stderr to a file, the program output is still printed on the console and is not written to the file. When I redirect stderr, the wine output goes away, but the program's output is stilled printed on screen. wine program.exe > out # File is empty, program output printed on screen wine program.exe 2> out # Wine output gets redirected to file, program output still printed on screen If I redirect both, the output is neither printed on screen nor written to the file. **Edit:** On Windows, behavior is similar, but when redirecting both, everything is still printed on screen. Here are some examples with the complete output. $ wine program.exe fixme:winediag:start_process Wine Staging 1.9.23 is a testing version containing experimental patches. fixme:winediag:start_process Please mention your exact version when filing bug reports on winehq.org. output by program.exe fixme:msvcrt:__clean_type_info_names_internal (0x100aaa54) stub When I try to redirect the output, this happens: $ wine program.exe > out 2>&1 $ cat out fixme:winediag:start_process Wine Staging 1.9.23 is a testing version containing experimental patches. fixme:winediag:start_process Please mention your exact version when filing bug reports on winehq.org. fixme:msvcrt:__clean_type_info_names_internal (0x100aaa54) stub I.e., the program's console output is completely missing. The program still works fine and writes some files it's supposed to write. As a check, I did the same with pngcrush, and I get what I'd expect. Without redirection: $ wine pngcrush_1_8_10_w32.exe test.png out.png fixme:winediag:start_process Wine Staging 1.9.23 is a testing version containing experimental patches. fixme:winediag:start_process Please mention your exact version when filing bug reports on winehq.org. | pngcrush-1.8.10 | Copyright (C) 1998-2002, 2006-2016 Glenn Randers-Pehrson | Portions Copyright (C) 2005 Greg Roelofs | This is a free, open-source program. Permission is irrevocably | granted to everyone to use this version of pngcrush without | payment of any fee. | Executable name is pngcrush_1_8_10_w32.exe | It was built with bundled libpng-1.6.26 | and is running with bundled libpng-1.6.26 | Copyright (C) 1998-2004, 2006-2016 Glenn Randers-Pehrson, | Copyright (C) 1996, 1997 Andreas Dilger, | Copyright (C) 1995, Guy Eric Schalnat, Group 42 Inc., | and bundled zlib-1.2.8.1-motley, Copyright (C) 1995 (or later), | Jean-loup Gailly and Mark Adler, | and using "clock()". | It was compiled with gcc version 4.8.0 20121015 (experimental). Recompressing IDAT chunks in test.png to out.png Total length of data found in critical chunks = 431830 Critical chunk length, method 1 (ws 15 fm 0 zl 4 zs 0) = 495979 Critical chunk length, method 2 (ws 15 fm 1 zl 4 zs 0) > 495979 Critical chunk length, method 3 (ws 15 fm 5 zl 4 zs 1) = 495354 Critical chunk length, method 6 (ws 15 fm 5 zl 9 zs 0) = 457709 Critical chunk length, method 9 (ws 15 fm 5 zl 2 zs 2) > 457709 Critical chunk length, method 10 (ws 15 fm 5 zl 9 zs 1) = 451813 Best pngcrush method = 10 (ws 15 fm 5 zl 9 zs 1) = 451813 (4.63% critical chunk increase) (4.63% filesize increase) CPU time decode 4.407583, encode 17.094248, other 4294967296.000000, total 17.180143 sec With redirection: $ wine pngcrush_1_8_10_w32.exe test.png out.png > out 2>&1 $ cat out fixme:winediag:start_process Wine Staging 1.9.23 is a testing version containing experimental patches. fixme:winediag:start_process Please mention your exact version when filing bug reports on winehq.org. | pngcrush-1.8.10 | Copyright (C) 1998-2002, 2006-2016 Glenn Randers-Pehrson | Portions Copyright (C) 2005 Greg Roelofs | This is a free, open-source program. Permission is irrevocably | granted to everyone to use this version of pngcrush without | payment of any fee. | Executable name is pngcrush_1_8_10_w32.exe | It was built with bundled libpng-1.6.26 | and is running with bundled libpng-1.6.26 | Copyright (C) 1998-2004, 2006-2016 Glenn Randers-Pehrson, | Copyright (C) 1996, 1997 Andreas Dilger, | Copyright (C) 1995, Guy Eric Schalnat, Group 42 Inc., | and bundled zlib-1.2.8.1-motley, Copyright (C) 1995 (or later), | Jean-loup Gailly and Mark Adler, | and using "clock()". | It was compiled with gcc version 4.8.0 20121015 (experimental). Recompressing IDAT chunks in test.png to out.png Total length of data found in critical chunks = 431830 Critical chunk length, method 1 (ws 15 fm 0 zl 4 zs 0) = 495979 Critical chunk length, method 2 (ws 15 fm 1 zl 4 zs 0) > 495979 Critical chunk length, method 3 (ws 15 fm 5 zl 4 zs 1) = 495354 Critical chunk length, method 6 (ws 15 fm 5 zl 9 zs 0) = 457709 Critical chunk length, method 9 (ws 15 fm 5 zl 2 zs 2) > 457709 Critical chunk length, method 10 (ws 15 fm 5 zl 9 zs 1) = 451813 Best pngcrush method = 10 (ws 15 fm 5 zl 9 zs 1) = 451813 (4.63% critical chunk increase) (4.63% filesize increase) CPU time decode 4.339310, encode 17.137527, other 4.294083, total 17.182100 sec What could be the cause of that not working for the other program? wine stdout stderr io-redirection
Thomas W. (323 rep)
Dec 8, 2016, 12:48 PM • Last activity: May 20, 2025, 09:40 AM
0 votes
1 answers
61 views
Why `dumpe2fs` writes its version number to standard error?
I want to do a simple `grep` on `dumpe2fs` output but I keep seeing `dumpe2fs 1.46.5 (30-Dec-2021)` showing up after my `grep`: ``` $ sudo dumpe2fs -h /dev/sdb2 | grep 'Block count:' dumpe2fs 1.46.5 (30-Dec-2021) Block count: 1247300 ``` But if I redirect `stderr` of `dumpe2fs` to `stdout` using `|&...
I want to do a simple grep on dumpe2fs output but I keep seeing dumpe2fs 1.46.5 (30-Dec-2021) showing up after my grep:
$ sudo dumpe2fs -h /dev/sdb2 | grep 'Block count:'
dumpe2fs 1.46.5 (30-Dec-2021)
Block count:              1247300
But if I redirect stderr of dumpe2fs to stdout using |& then it will just work fine as expected:
$ sudo dumpe2fs -h /dev/sdb2 |& grep 'Block count:'
Block count:              1247300
The question is why dumpe2fs is writing version number dumpe2fs 1.46.5 (30-Dec-2021) to stderr?!
kaptan (325 rep)
Feb 20, 2025, 01:37 AM • Last activity: Mar 7, 2025, 02:59 PM
117 votes
5 answers
14295 views
Do progress reports/logging information belong on stderr or stdout?
Is there an official POSIX, GNU, or other guideline on where progress reports and logging information (things like "Doing foo; foo done") should be printed? Personally, I tend to write them to stderr so I can redirect stdout and get only the program's actual output. I was recently told that this is...
Is there an official POSIX, GNU, or other guideline on where progress reports and logging information (things like "Doing foo; foo done") should be printed? Personally, I tend to write them to stderr so I can redirect stdout and get only the program's actual output. I was recently told that this is not good practice since progress reports aren't actually errors and only error messages should be printed to stderr. Both positions make sense, and of course you can choose one or the other depending on the details of what you are doing, but I would like to know if there's a commonly accepted standard for this. I haven't been able to find any specific rules in POSIX, the GNU coding standards, or any other such widely accepted lists of best practices. We have a few similar questions, but they don't address this exact issue: * https://unix.stackexchange.com/q/79315/22222 : The accepted answer suggests what I tend to do, keep the program's final output on stdout and anything else to stderr. However, this is just presented as a user's opinion, albeit supported by arguments. * https://unix.stackexchange.com/q/8813/22222 : This is specific to help messages but cites the GNU coding standard. This is the sort of thing I'm looking for, just not restricted to help messages only. So, are there any official rules on where progress reports and other informative messages (which aren't part of the program's actual output) should be printed?
terdon (251585 rep)
Dec 20, 2016, 10:13 AM • Last activity: Feb 23, 2025, 02:37 PM
5 votes
2 answers
830 views
What is the most succinct way of terminating the rest of a pipeline if a command fails?
Consider the following: command1 | command2 | command3 As I understand pipelines every command is run regardless of any errors which may occur. When a command returns stderr, it is not piped to the next command, but the next one is still run (unless you use `|&`). I want any error which may occur to...
Consider the following: command1 | command2 | command3 As I understand pipelines every command is run regardless of any errors which may occur. When a command returns stderr, it is not piped to the next command, but the next one is still run (unless you use |&). I want any error which may occur to terminate the rest of the pipeline. I thought set -o pipefail would accomplish this, but it simply terminates anything which may come after the pipeline if anything in the pipeline failed, ie: (set -o pipefail; cmd1 | cmd2 && echo "I won't run if any of the previous commands fail") So, What is the most succinct way terminate the **rest** of the pipeline if any of its commands fail? I also need it to exit with the proper stderr of the command which failed. I'm doing this from a command-line context, not a shell script, hence why I'm looking for brevity. Thoughts?
Audun Olsen (217 rep)
May 9, 2019, 11:40 AM • Last activity: Feb 4, 2025, 07:47 AM
86 votes
5 answers
21662 views
Can I configure my shell to print STDERR and STDOUT in different colors?
I want to set my terminal up so `stderr` is printed in a different color than `stdout`; maybe red. This would make it easier to tell the two apart. Is there a way to configure this in `.bashrc`? If not, is this even possible? - - - **Note**: This question was merged with [another](https://unix.stack...
I want to set my terminal up so stderr is printed in a different color than stdout; maybe red. This would make it easier to tell the two apart. Is there a way to configure this in .bashrc? If not, is this even possible? - - - **Note**: This question was merged with [another](https://unix.stackexchange.com/q/53563/22565) that asked for stderr, stdout *and the user input echo* to be output in *3 different colours*. Answers may be addressing either question.
Naftuli Kay (41346 rep)
May 1, 2011, 10:59 PM • Last activity: Oct 13, 2024, 01:22 PM
0 votes
2 answers
665 views
STDOUT + STDERR output ... is there any difference between considering the output to be an empty string vs NULL
I'm writing some application code that is used to execute Linux shell commands, and it then logs the command details into an SQL database. This includes the output of STDOUT + STDERR (separately). After the command has been executed, and assuming the process didn't output anything... could there be...
I'm writing some application code that is used to execute Linux shell commands, and it then logs the command details into an SQL database. This includes the output of STDOUT + STDERR (separately). After the command has been executed, and assuming the process didn't output anything... could there be any reason to leave the STDOUT/STDERR fields as NULL -vs- setting them to be empty strings? To put the question another way: is there technically any difference between these two things? - A process that doesn't output anything to STDOUT - A process that outputs an empty string to STDOUT (and nothing else) And to put the question another way again... does it make sense to make these columns NOT NULL in SQL?
LaVache (423 rep)
Dec 6, 2018, 03:02 AM • Last activity: Oct 6, 2024, 09:27 AM
0 votes
2 answers
429 views
Redirecting stdout with > and stderr with >> to same file leaves out stderr
I'm redirecting stdout and stderr to the same file by using > and >> respectively: ``` rsync -a --exclude cache/ src_folder/ target_folder/ 1>out_err.log 2>>out_err.log ``` However the stderror is not logged in the file. What happens to the stderror when using >> instead of > to redirect both to the...
I'm redirecting stdout and stderr to the same file by using > and >> respectively:
rsync -a --exclude cache/ src_folder/ target_folder/ 1>out_err.log 2>>out_err.log
However the stderror is not logged in the file. What happens to the stderror when using >> instead of > to redirect both to the same file? My intention was to write stdout to a new file and then append stderr to that same file.
bit (1176 rep)
Sep 26, 2024, 08:48 PM • Last activity: Sep 27, 2024, 09:38 AM
2 votes
1 answers
120 views
In zsh, annotate each line in a file to which both stdout and stderr have been redirected with the line's source (stdout or stderr)
In zsh, how can I annotate each line in a file to which both stdout and stderr have been redirected with the line's source (stdout or stderr)? I want output with the source name prepended to the line, like: ``` stdout: stderr: ```
In zsh, how can I annotate each line in a file to which both stdout and stderr have been redirected with the line's source (stdout or stderr)? I want output with the source name prepended to the line, like:
stdout: 
stderr:
XDR (451 rep)
Aug 14, 2024, 08:18 AM • Last activity: Aug 14, 2024, 08:52 AM
0 votes
1 answers
79 views
How can I get stderr from mbuffer written to log file when using tee?
Having a bash script that essential only doing: ``` mbuffer --md5 -i dummy.tar -o /dev/null ``` A user of this script wants to use tee and store the output messages in a log file. ``` ./script.sh 2>&1 | tee log.txt ``` Everything is visible on terminal but nothing is written to log.txt. How can I do...
Having a bash script that essential only doing:
mbuffer --md5 -i dummy.tar -o /dev/null
A user of this script wants to use tee and store the output messages in a log file.
./script.sh 2>&1 | tee log.txt
Everything is visible on terminal but nothing is written to log.txt. How can I do to get output on both terminal and in file? Just running in a terminal winds up the same, nothing in log.txt:
mbuffer --md5 -i dummy.tar -o /dev/null 2>&1 | tee log.txt
Tried on Ubuntu and Rocky Linux. Also tried
stdbuf -e 0 -o 0 mbuffer --md5 -i dummy.tar -o /dev/null 2>&1 | tee log.txt
TopCatSE (3 rep)
Jul 16, 2024, 09:41 AM • Last activity: Jul 18, 2024, 10:59 AM
0 votes
1 answers
179 views
How to put all function/command call output results to different corresponding vars: for stderr, for stdout, for string result and for return code?
I want to extend question [How to store standard error in a variable](https://stackoverflow.com/q/962255/1455694) and get general solution (bash function or functions) to extract from the called function/command together with `standard error` also all other possible outcomes. The function should cap...
I want to extend question [How to store standard error in a variable](https://stackoverflow.com/q/962255/1455694) and get general solution (bash function or functions) to extract from the called function/command together with standard error also all other possible outcomes. The function should capture and return as vars for the called function/command the following: - stderr - stdout - result string out var - return code API for the function should be convenient to use. --- Example of test function that produces all different output results:
func_to_test_all_outs() {
    local param="${1:?}"; shift
    local -n out_result=${1:?}; shift

    echo "test error output" >&2
    echo "test normal output"

    out_result=""
    if [[ "$param" = "return_string_result" ]]; then
        out_result="result string"
    fi

    return 3
}
More comprehensive/general example of test function that produces all different output results including spawning background processes to produce stout and stderro, interleaving stdout/stderr output, and including leading/trailing/mid white space plus potential command injection, variable expansion, and globbing chars in output streams and does redirection of FD3 in case the calling script relies on that:
func_to_test_all_outs() {
    local param="${1:?}"; shift
    local -n out_result=${1:?}; shift

    ( sleep 2; printf '\n   first  \n$RANDOM *\nerror output\n' >&2; ) &
    exec 3>&1
    printf ' first  \n$(date)\n*\nnormal output\n\n' >&3

    exec 3>&2
    printf '\nsecond $RANDOM *\nerror output\n\n\n' >&3
    ( sleep 2; printf 'second\ntest\n$(date)\n*\nnormal output\n\n' ) &

    ( printf 'third\n$(date)\n*\nnormal output\n\n' ) &

    out_result=""
    if [[ "$param" = "return_string_result" ]]; then
        printf -v out_result '\n\nresult\t\n\nstring\n\n\n'
    fi

    return 127
}
Anton Samokat (289 rep)
Jun 27, 2024, 01:02 PM • Last activity: Jun 30, 2024, 11:40 AM
1 votes
2 answers
1324 views
Is it possible to read from stderr in a bash script?
I have a bash script like this: #!/bin/bash while read -r -a line do ... parse $line in some way done This script is executed by piping the command from another program: some-random-program | myscript.sh This works as long as some-random-program sends its output to stdout. However, if the script sen...
I have a bash script like this: #!/bin/bash while read -r -a line do ... parse $line in some way done This script is executed by piping the command from another program: some-random-program | myscript.sh This works as long as some-random-program sends its output to stdout. However, if the script sends output to stderr, then my script sees no output. I know I can do this: some-random-program 2>&1 | myscript.sh **My question is this:** is there a way to get myscript.sh to read from stderr so that the "2>&1" (or any variation of it) *is not necessary*? I thought I could do this: while read -r -a line do ... parse $line in some way done < /dev/stderr But that didn't work. The script never sees any input.
lord_nimon (141 rep)
May 21, 2024, 09:24 PM • Last activity: May 21, 2024, 10:52 PM
3 votes
3 answers
1722 views
When and where are the standard in, out, and error file descriptors first opened in linux?
Where are stdin, stdout, and stderr (the fds) **first** opened? Is it the kernel that does it? And when and where are the symlinks /dev/std{in,out,err} made? Where is the code that does it? I assume it is in the linux kernel source code but I wasn't able to find where it happens even after a search...
Where are stdin, stdout, and stderr (the fds) **first** opened? Is it the kernel that does it? And when and where are the symlinks /dev/std{in,out,err} made? Where is the code that does it? I assume it is in the linux kernel source code but I wasn't able to find where it happens even after a search in the archlinux 6.5.3-arch1-1 linux kernel github repo. edit: please, if you are downvoting this question can you explain why so I can make it better? I would really like to know about this question. It is not easy to find the answer.
Elfen Dew (69 rep)
Sep 22, 2023, 12:31 AM • Last activity: May 21, 2024, 03:25 AM
3 votes
1 answers
2805 views
Print clang include path and store in file
I'm writing a program that needs to pull in the clang include paths. Thanks to [Dump include paths from g++][1] I'm half-way there. The command I'm using is: clang++ -E -x c++ - -v stdout.txt clang++ -E -x c++ - -v stderr.txt So where is the output being redirected to and what command do I need to e...
I'm writing a program that needs to pull in the clang include paths. Thanks to Dump include paths from g++ I'm half-way there. The command I'm using is: clang++ -E -x c++ - -v stdout.txt clang++ -E -x c++ - -v stderr.txt So where is the output being redirected to and what command do I need to execute to properly store off the information that is printed to console?
Max (131 rep)
Jan 15, 2020, 07:23 PM • Last activity: Apr 19, 2024, 08:49 PM
Showing page 1 of 20 total questions