Skip to content
Advertisement

Tag: c++

Rewrite at the beginning of the file

I was trying to rewriting text at beginning of file but facing the following: The header file is test.h: The source file is test.c : The main file is main.c: The make file is: The out put was expected is: But it is replacing first few characters of the first line. Where I am going wrong? Answer The output is

escape alarm() process timeout with nohup or setsid?

I have a monitoring application, Zabbix agent, that allows me to run arbitrary commands/scripts and grab the return value. The agent is configured with a timeout and any command that exceeds the timeout will be killed. For every command that is run, it first sets the timeout via alarm(timeout) and then forks the agent process before running the command in

Sending an arrow key with fprintf

I’m testing out pipes and have hit a little road block. I want to be able to simulate pressing the right arrow key through a file pointer opened by popen. The file pointer opens a display program on a different terminal, much like a projector. I would like to send a signal to advance the next image (the right arrow

Why doesn’t Linux prevent spawning infinite number of processes and crashing?

With the very simple code below, my system (Ubuntu Linux 14.04) simply crashes not even letting my mouse respond. I had to force quit with the power button. I thought Linux is a stable OS tolerable of handling such basic program errors. Did I miss something? Answer Congratulations, you’ve discovered the fork bomb. There are shell one-liners that can wreak

How does read(2) in Linux C work?

According to the man page, we can specify the amount of bytes we want to read from a file descriptor. But in the read’s implementation, how many read requests will be created to perform a read? For example, if I want to read 4MB, will it create only one request for 4MB or will it split it into multiple small

Advertisement