0

I would like to know if when we call printf without connecting a monitor (and uninstalling any driver related to the screen), does a driver get called anyway?

1 Answer 1

3

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 functions), you produce a byte stream on stdout.

What the OS does with that byte stream entirely depends on what the stdout descriptor is connected to. You can connect it to a file (and then all the OS layers for the file system get called, inclusive "drivers" if the file system is backed by physical hardware). You can connect it to /dev/null, then the "driver" for this device is called (which will just ignore it). You can pipe it to another process.

That's unrelated to if you have a monitor connected, or if all "drivers related to the screen" are installed or not.

So please read up a bit on Unix and Linux basics, and terminal emulators, and terminal settings; that will help you understand the many layers that are involved in that.

2
  • so if I understand you answer correctly, the printf will write to the file and not call any driver. Only later a driver may be called if the stdout is connected to some kind of device? and if a screen is not connected then no driver will be called?
    – Ariel Yael
    Jun 29 at 13:29
  • No. printf will (eventually) do OS calls that tell the OS that the process writes to stdout. What happens then depends entirely what stdout is connected to. Also, your idea that there is somehow "a driver" involved is extremely naive. During the processing of the output lots of things get called that you could call a "driver" (or not). As I said, please read up a bit on how this all works.
    – dirkt
    Jun 29 at 19:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.