Skip to main content

proper Proper way to write C code that injects message into /var/log/messages?

inIn Linux, RHEL-8.10 or later if it matters, I would like to write some C code that takes in various parameters and upon a certain condition issues a system("init 0") to shutdown the system. Before issuing the shutdown, I would like to throw a one line message into /var/log/messages that states system being shut down by ron's code so that I have a record of when that has happened.

How do you properly write into /var/log/messages  ?

Obviously I can do an fopen("/var/log/messages, "a") and a simple fprintf but that seems like a bit of a hack.

proper way to write C code that injects message into /var/log/messages

in Linux, RHEL-8.10 or later if it matters, I would like to write some C code that takes in various parameters and upon a certain condition issues a system("init 0") to shutdown the system. Before issuing the shutdown, I would like to throw a one line message into /var/log/messages that states system being shut down by ron's code so that I have a record of when that has happened.

How do you properly write into /var/log/messages  ?

Obviously I can do an fopen("/var/log/messages, "a") and a simple fprintf but that seems like a bit of a hack

Proper way to write C code that injects message into /var/log/messages?

In Linux, RHEL-8.10 or later if it matters, I would like to write some C code that takes in various parameters and upon a certain condition issues a system("init 0") to shutdown the system. Before issuing the shutdown, I would like to throw a one line message into /var/log/messages that states system being shut down by ron's code so that I have a record of when that has happened.

How do you properly write into /var/log/messages?

Obviously I can do an fopen("/var/log/messages, "a") and a simple fprintf but that seems like a bit of a hack.

deleted 8 characters in body
Source Link
ron
  • 9.1k
  • 19
  • 82
  • 149

in Linux, RHEL-8.10 or later if it matters, I would like to write some C code that takes in various parameters and upon a certain condition issues a system("init 0") to shutdown the system. Before issuing the shutdown, I would like to throw a one line message into /var/log/messages that states system being shut down by ron's code so that I have a record of when that has happened.

How do you properly write into /var/log/messages ?

Obviously I can do an fopen("/var/log/messages, "a") and a simple fprintf but that doesn't seems like a bit of a hack

in Linux, RHEL-8.10 or later if it matters, I would like to write some C code that takes in various parameters and upon a certain condition issues a system("init 0") to shutdown the system. Before issuing the shutdown, I would like to throw a one line message into /var/log/messages that states system being shut down by ron's code so that I have a record of when that has happened.

How do you properly write into /var/log/messages ?

Obviously I can do an fopen("/var/log/messages, "a") and a simple fprintf but that doesn't seems like a bit of a hack

in Linux, RHEL-8.10 or later if it matters, I would like to write some C code that takes in various parameters and upon a certain condition issues a system("init 0") to shutdown the system. Before issuing the shutdown, I would like to throw a one line message into /var/log/messages that states system being shut down by ron's code so that I have a record of when that has happened.

How do you properly write into /var/log/messages ?

Obviously I can do an fopen("/var/log/messages, "a") and a simple fprintf but that seems like a bit of a hack

Became Hot Network Question
Source Link
ron
  • 9.1k
  • 19
  • 82
  • 149

proper way to write C code that injects message into /var/log/messages

in Linux, RHEL-8.10 or later if it matters, I would like to write some C code that takes in various parameters and upon a certain condition issues a system("init 0") to shutdown the system. Before issuing the shutdown, I would like to throw a one line message into /var/log/messages that states system being shut down by ron's code so that I have a record of when that has happened.

How do you properly write into /var/log/messages ?

Obviously I can do an fopen("/var/log/messages, "a") and a simple fprintf but that doesn't seems like a bit of a hack