Skip to content

clear a Pipe in C

I’m sending data from one process to another pipe and I want to clear the pipe after reading. Is there a function in C that can do this ? Answer Yes. It’s just the read function offered by the stdio library. You have to invoke it as many times as you need in order to be sure the pipe will

C++ + linux handle SIGPIPE signal

Yes, I understand this issue has been discussed many times. And yes, I’ve seen and read these and other discussions: 1 2 3 and I still can’t fix my code myself. I am writing my own web server. In the next cycle, it listens on a socket, connects each new client and writes it to a vector. Into my cl…

Usage of getc with a file

To print the contents of a file one can use getc: How efficient is the getc function? That is, how frequently does it actually do operating system calls or something that would take a non-trivial amount of time? For example, let’s say I had a 10TB file — would calling this function trillions of ti…

Command not found in Linux machine

I installed Fortify software in Linux using the user “Kiran”. When I typed sourceanalyzer –v using the user “Kiran” I got: But, when I searched using the user “root”, I am getting command not found. Can someone please help me on how to find the version using the root …

issues using waitpid() with large number of child process

I have a c program to create a TCP socket and keep waiting for a connection in an infinite loop. Each time a client connected to the program, I would spawn a new child process to handle the client request. My program could only exit with signal interrupt (e.g. ctrl+c). I don’t want the parent process ha…

Text-cursor position handling in C (under Linux)

I’m trying to reposition the text-cursor to top left corner of the console each frame, so the resulted square rendered at the same position I found that this is possible in windows by including <windows.h>: How can I do that in Ubuntu? Answer [update] Oops, sorry, I didn’t notice the “…