Skip to content

Tag: c++

Draw table in C — like table on manual page of Linux

I want to make nice tables like you see on some manual page of Linux documentation in C programming language. Is there any library or functions to create a table like them. For example a table that you can find on man syslog like the following, produced by running man syslog: Answer You can take a look at the…

Serial port hangs on close()

I developed this simple kernel module, which emulates a serial port by using a FIFO queue and a timer (read from hardware : out from the queue, write to hardware : insert in the queue). Source code is shown next. Then, I wrote a simple test-application which configures the port settings (baud rate, parity, st…

Weird behavior in GDB when defaulting copy/move constructors

I have the following code which seems to behave weirdly in GDB depending if the copy/move constructors are defaulted or not. I fire up GDB, add a breakpoint on the last cout in main and run “p t.get()” and I expect it to be 42 but depending on the value of the macro CUSTOM I get either 42 (when CU…

Control loop time with usleep

I try to make sure the execution time of each loop to 10ms with usleep , but sometimes it exceeds 10ms. I have no idea how to solve this problem, is it proper to use usleep and gettimeofday in this case? Please help my find out what i missed. Result: 0.0127289 0.0136499 0.0151598 0.0114031 0.014801 Answer To …

How do I find a system memory leak in linux?

I’ve got a monolithic piece of software, a game on a basic linux kernel, that seems to leak memory in swap space. The memory usage of the process itself is reported as constant over a day or so but the free memory on the system is consistently decreasing until there is no more physical ram space. There …

Cannot insert breakpoints. Addresses with low values

I’m trying to debug this simple C program: But when I disassemble the main function I get this: And this is already pretty strange because addresses starts with a prefix of 4… for 32 bit executables and 8… for 64 bit executables I think. But going on I then put a breakpoint: I run it and I g…

Unnamed unix domain socket has wrong address length

When reading the address of a sending unix datagram domain socket in this minimal example program, I am getting an address length of 0, but the man page for unix domain sockets specifies that: unnamed: A stream socket that has not been bound to a pathname using bind(2) has no name. Likewise, the two sockets c…