Skip to content
Advertisement

Tag: c++

How to receive a file using sendfile?

send a file with sendfile is easy: but how to receive a file using sendfile? since I don’t know the length of the file, should I send the file length first? There seems to be two ways of doing this: send the filestat.len first use a loop in the receive end: Which one is better? Should I handle the buffer

Epoll_wait returning events on closed file descriptor

I’m working with a multithreaded embedded application in which epoll is used for IO in one of the threads. I’m relying on a particular feature of epoll that specifies that closing a file descriptor automatically removes it from the epoll set (Question/Answer 6 in man 7 epoll). In this case, the file descriptor close is done in the same thread

Disabling disk cache in linux

In a class project my teacher told us to make some code evaluations (C language) and to do so we need to disable the disk caching during the tests. Currently I’m using Ubuntu 12.04, how can I do this? Thanks. Answer You need root access to do this. You can run hdparm -W 0 /dev/sda command to disable write caching,

gdb backtrace with no user input?

I’m wondering if it’s possible to launch an application via GDB, on a SegFault write the backtrace to a file (to look at later), and then exit GDB all without any user input. I’m running an application from a shell script in an infinite loop (so if it crashes it reloads) on OS boot from a non-interactive session. The application

obtaining received signal strength of neighboring devices

I use AR9271 chipset usb WiFi device on Debian 7 on kernel 3.12.rc5. I use ath9k_htc and nl80211 drivers. I create an ad-hoc WLAN via wpa_supplicant 2.0 and I would like to obtain received signal strength of the neighboring device in a C program. What function or API can I use to obtain that information? Answer Edit: Did not notice

Capturing user-space variables at “perf” events

I’ve now been able to get perf to capture a user-space stack`, but I’m not sure how to convince it to capture values passed by reference as pointers, or to snapshot globals of interest. Specifically, I’m trying to analyse the system-wide performance of PostgreSQL under various loads with and without a performance related patch. One of the key things I

Segfault from ld-linux in my build of glibc

Running Ubuntu 10.04 Downloaded the source and did the following: This works: This fails: But this works: False, grep, and cat and everything else I’ve tried in /bin segfault in the same manner. Is there an issue with the source? Am I compiling it incorrectly? Also of note is that i downloaded the correct version (slightly newer) for the raspberry

O_DIRECT vs. O_SYNC on Linux/FreeBSD

I’m writing a program that runs on both Linux and FreeBSD, and I want to make sure that the data is actually written to the file on the physical device when each write() returns, so that my data won’t get lost by accident (eg, power lost, the process is interrupted unexpected, etc.). According to OPEN(2) man page, on Linux (higher

Advertisement