The following is my C file: It contains only return statement. But if I use the size command, it shows the output like this: Even though my program does not contain any global variable, or undeclared data. But, the output shows data segment have 252 and the bss have 8 bytes. So, why the output is like this? what is
Tag: c++
Child process starts after parent process
I have a simple code to test the fork() function. It didn’t work as I expected. My expectation is: parent’s result and child’s result appear alternately. Can someone explain this and teach me how to fix it? Thanks! Answer The explanation is simple. Scheduling of processes is up to the kernel. If this is a single core processor then in
How fork() function works in this program?
I’m having some trouble with this program. I know what a fork() function does. It is used to create a new process from an existing process. The new process is called the child process, and the existing process is called the parent. The parent returnes the child’s pid and the child returns 0. That said, I find hard to understand
Webrtc2sip: error adding symbols: DSO missing from command line
I am trying to compile following code webrtc2sip but getting following error. Edit: I have tried following option in Makefile but no luck 🙁 Answer Solution: Finally find it, used following option and it works!
Why is a multithreaded C program forced to a single CPU on Mac OS X when system() is used in a thread?
I encountered a strange difference in the behavior of a program using pthreads between Linux and Mac OS X. Consider the following program that can be compiled with “gcc -pthread -o threadtest threadtest.c”: Running the resulting executable on a 4-core Mac OS X machine results in the following behavior: Note that the number of actual cores is probably not even
Is it necessary to write a “portable” if (c == ‘n’) to process cross-platform files?
This thinking comes from a discussion about a practical problem Replacing multiple new lines in a file with just one. Something wrong happened while using a cygwin terminal running on a windows 8.1 machine. Since the end-of-line terminator would be different, like n, r, or rn, is it necessary to write a “portable” if(c==’n’) to make it work well on
Redirect stdout to a external program in C/C++
I have a program called capture that reads the webcam data and output to the avconv program. Now I have to output to avconv inside my C program. So, instead of output to the stoud: I need to do do something like that: How can I do that? Answer You can use popen() for this purpose. then use fwrite() to
Linux – make sure a core is exclusively saved for critical tasks
I have a process that is launched on a Linux-based machine with exactly two cores. Let’s assume my process is the only process in the system (I will ignore other processes and even the system’s ones). My process is divided to two parts: Critical performance code Low priority code Also let’s assume my main process was launched on Core 0,
SEGFAULT after recv from socket
I have next trouble: after receiving data from sockets, server app generates segfault and shutdown. Code of client and server side are below. server: Client: In other words, client connected successfully. But after sending message, server generate segm fault error. What went wrong? Answer When running the code it seg faults at: Package is a struct with two members nick
makefile linking does not work (although no error message)
I am having issue with Makefile that I produced. It consists of one .cpp file with main() inside and I want to create executable from it. While putting in terminal make command I get following: While putting first make STutorial.o (.o created) and then make get this: Firstly, why make does not go from the beginning? Secondly, why this reference