New answers tagged

3 votes

Calling printf without a connected monitor

You are confusing several things. All Unix processes have special file descriptors called stdin (standard in), stdout (standard out), and stderr (standard error). If you call printf (or similar ...
user avatar
  • 29.1k
4 votes

passwd source code

If you’re referring to the “shadow-utils” implementations of passwd, you’ll find the test here: /* * The program behaves differently when executed by root than when * executed by a ...
user avatar
1 vote

VT100 Escape codes and TTY interaction: Why `open` a TTY device as opposed to using stdin/stdout

Opening and using /dev/tty ensures that the process has a controlling terminal, and that that’s where the escape codes actually go. Writing to standard output and reading from standard input is ...
user avatar
7 votes
Accepted

why does my Makefile keep recompiling when there are no changes?

You’re using phony targets, i.e. targets with a useful name but whose recipes don’t produce the target. That is to say, make ends up trying to build the all_functions target, but the associated recipe ...
user avatar
2 votes
Accepted

Dealing with different prototypes of pipe()

The pipe man page you found has two different purposes: It documents the system call interface used by the Linux kernel. It documents the system call wrappers provided by the GNU C library on Linux. ...
user avatar
1 vote

Dealing with different prototypes of pipe()

If I want to be as cross-platform as possible, do I now have to write code that compiles when it is given either prototype? No, there's no need here. You're looking at the section 2 manpage entry, ...
user avatar
  • 2,575
2 votes
Accepted

make && echo "hello" only print hello when make succeeds (kernel)

Because of the pipe to tee, the second make’s exit status is ignored. To get the behaviour you want, you need to enable pipefail: change the set -xe line to set -xe -o pipefail See Debugging scripts, ...
user avatar
1 vote
Accepted

Master script calls helper scripts which calls C program, do not know how to get return value of C program

Since you run the helper script with bash -e, you will set the errexit shell option in the script. This shell option will cause the script to terminate if a simple command (like your C command) ...
user avatar
  • 271k
5 votes

What is the behavior of O_APPEND with lseek: can you rewrite a file opened in O_APPEND?

Is it possible when a file is open with O_APPEND to lseek to the top and rewrite the file? No. Per the POSIX documentation for write(): If the O_APPEND flag of the file status flags is set, the file ...
user avatar
  • 3,467
0 votes

What is the behavior of O_APPEND with lseek: can you rewrite a file opened in O_APPEND?

No, you can't rewrite the file. The file offset is being set to the end before every write is executed.
user avatar
  • 405

Top 50 recent answers are included