I’m writing a function, which, given an argument, will either redirect the stdout to a file or read the stdin from a file. To do this I close the file descriptor associated with the stdout or stdin, so that when I open the file it opens under the descriptor that I just closed. This works, but the problem is that
Tag: c++
C wait3() int* status or int* stat_loc
I indeed to use wait3(). I have been looking what exactly is status/stat_loc but I couldn’t find it anywhere. Any explanation is greatly appreciated! Answer man wait explains the semantics of status:
gdb how to get thread name displayed
There are many threads created in my application. some of the threads name are visible in the gdb while i execute the command ‘info threads’, others are not displayed. How to get all the thread name itself instead of the hex value like 0xb7fe1424 Answer If you upgrade to gdb 7.3 or later, “info thread” will show thread names; at
“SO” file conversion to readable format
Is there any way to convert “.so” file into source code or some in readable format. Answer Source code is probably hard, since the .so doesn’t “know” which language it was written in. But you can browse around in the assembly code by doing something like this:
g++ 4.6.1 compiler error: Error: unknown pseudo-op: `.cfi_personality’
I have a file which compiles without errors or warnings on my macbook pro running osx (snow leopard) using g++ (4.6.1). I just uploaded it to our linux cluster (not run by me) and tried to compile there (also using gcc 4.6.1). This time I many strange error messages with the assembler. How do I interpret the following error? Answer
How can I do congestion control for a UDP protocol?
I have a custom UDP protocol with multiple senders/receivers designed to send large files around as fast as possible. It is client/server based. How can I detect congestion on the LAN to slow the rate of UDP packets being sent? EDIT: please, no comments on the use of UDP whether it’s suitable or not. This protocol uses UDP but reassembles
How can I obtain a case sensitive path on Linux without directory iteration?
Given a mounted cifs file system /network/cifs which is case insensitive, how do I obtain the case sensitive path using C? For example, the fs has a file /network/cfis/Adena/t.txt. Given /network/cfis/AdEnA/T.txt (which properly resolves), I want /network/cfis/Adena/t.txt. I know one way to do it is to recursively iterate over the path, match them in all lower case, and get the
Is malloc/free a syscall or a library routine provided by libc?
If malloc/free is implemented as a library routine in libc, then is it implemented on top of the sbrk syscall or the mmap syscall, or something else? And to be general, does the function declared in sys/syscall.h contains ALL the system calls in the target machine? Answer malloc and free are standard C library functions which are to be implemented
High performance reading – linux/pthreads
I have moderately large binary file consisting of independent blocks like this: header1 data1 header2 data2 header3 data3 … The number of blocks, the size of each block and the total size of the file vary quite a lot, but typical numbers are ~1000 blocks and average blocksize 100kb. The files are generated by an external application which I have
.txt file is no longer written to by snmptrapd daemon after opening and closing with ifstream in C++
I am running Net-Snmp (environment is a virtual machine running Linux Mint OS 11) and have configured it to send trap information to a text file that I have called trapd.txt. If I reboot the VM, any trap that is generated is sent to the file no problem. However If I run a C++ program using ifstream to open it