I have a multithreaded server process, written in C/C++ that I am trying to profile with Google perftools. However when I run the process with perftools, pretty soon my server stops with a “syscall interrupted” error, that I think is being caused by the incoming SIGPROF. (The actual system call that is being interrupted is deep inside my call to
Tag: c++
qt5: why 2 processes and memory usage?
I uses 64 linux with fresh install of qt 5.1.0. I take example application qtbase/examples/widgets/widgets/lineedits and run, let’s call it qt5_lineedit, also I take the similar app from qt4 sources build it with qt4 library and run. And in htop I see that, there are two qt5_lineedit (I run only one, so it used 2 threads) and memory usage: VIRT
ioctl fails when trying to get more than 8 queue file descriptor from a tun interface
After I heared that after kernel 3.8 linux added multi queue ability to tun tap device with flag IFF_MULTI_QUEUE, I upgraded my kernel to 3.10 and have its header in /usr/src then I altered my c code to have a thread to open a new queue file descriptor each time neaded. but the thread could just open 8 queue (with
Counter increase in child & parent with fork()
I’ve a problem with this little program: I increase the counter in the child but in the parent the counter not increase… why? Thank you everyone Answer That’s because after fork, parent process and child process are different processes, and they each have their own copy of the variable count.
fprintf, error: format not a string literal and no format arguments [-Werror=format-security
when I try to compile fprintf(stderr,Usage) on Ubuntu I got this error: but when I compiled that on other linux distributions (RedHat, Fedora, SUSE) that is compiled successfully. Anyone has an idea? Answer You should use fputs(Usage, stderr); There is no need to use fprintf if you arn’t doing formatting. If you want to use fprintf, use fprintf(stderr, “%s”, Usage);
Extract pointer to data from GPtrArray
I’m using GPtrArray structure to hold pointers to chunks of dynamically allocated memory. As I need as simple as possible and correct freeing of memory I set callback g_ptr_array_new_with_free_func () which will free one element of pointer array. Thus when I call g_ptr_array_free() for all elements of array is called callback which correctly freeing allocated memory. Here is some pseudo
Linux C – implementing the ability that a program can update itself
I am writing a program in C on Linux environment (Debian-Lenny) and would like the program to be updated when an update is available (the program gets notified when a new update is available). I am looking for a way that the program can update itself. What I am thinking is that the main program invokes a new program to
Simple socket forwarding in linux
The scenario is pretty simple: Using TCP/IP I have a client which connects to me (server) I want to forward the data the socket sends me to another socket which I opened and the data I received from that socket backwards.Just like a proxy. Right now I have 1 thread one who listens from incoming connection and spawns another 2
Adding content to middle of file..without reading it till the end
I have read various questions/answers here on unix.stackexchange on how to add or remove lines to/from a file without needing to create a temporary file. https://unix.stackexchange.com/questions/11067/is-there-a-way-to-modify-a-file-in-place?lq=1 It appears all these answers need one to atleast read till end of the file, which can be time consuming if input is a large file. Is there a way around this? I would
How can I programmatically open the default browser and pass a URL in C/Linux?
Is there a convenient library call that allows me to open the default browser that I can use from C? I poked around in glib and didn’t see anything. There is xdg-open, and I can just system that I guess. Any better ideas? Answer If it is installed then xdg-open would work.