Skip to content
Advertisement

Tag: c++

Setting GDB hardware watchpoint/how to set software watchpoint

An earlier question explained that on x86 the size of objects being watched is limited by debug registers. As expected, I can “watch” a double variable. But I can’t watch a double datamember, for example, produces But when you try to continue execution, it says Could not insert hardware breakpoints: You may have requested too many hardware breakpoints/watchpoints. even though

How I can get ports associated to the application that opened them?

I need to get a list of all opened ports on my machine and what application opened them. I need to get this information programmatically. Thanks. Answer I was hoping a cleverer answer would appear. I did just this (programmatically in Python), in an attempt to rewrite a program called NetHogs. My version is here, specifically here is the module

how to read output of system(‘ls’)?

I am doing some file IO with c code. I have a particular pattern in my file. I can verify this by a shell command cat abc.txt | grep abc | wc -l. When I execute the same command using System(), it give proper output, but I have no clue how can I get its output into a variable and

How to change Keyboard Layout (a X11 API solution)

I want to change keyboard layout in Linux by programming, What X11’s API function does this? Answer I found one good solution. It’s a c++ class wrriten by Jay Bromley, that I can add to my app and using it. source code It’s very easy to use: you can read source code and found some another useful functions. for compiling

C write() doesn’t send data until close(fd) is called

So I have this test code to send “HELLO” over a USB serial port: The program executes fine and “HELLO” is sent but there is one problem. “HELLO” doesn’t seem to be sent when the write() function is called, but rather when the file descriptor is closed. I added the sleep(5) line above to test out this theory and sure

Linux, timerfd accuracy

I have a system that needs at least 10 mseconds of accuracy for timers. I went for timerfd as it suits me perfectly, but found that even for times up to 15 milliseconds it is not accurate at all, either that or I don’t understand how it works. The times I have measured were up to 21 mseconds on a

Uptime under linux in C

How can I retrieve uptime under linux using C? (without using popen and/or /proc) Thanks Answer Via top or via uptime, but I don’t know about any syscall, someone will for sure 🙂 uptime should be rather easy to parse. Just stumbled into this:

Why does setupterm terminate the program?

This is sample program from “Beginning Linux Programming” book: #include <stdio.h> #include <term.h> #include <curses.h> #include <stdlib.h> int main() { setupterm(“unlisted”, fileno(stdout), (int *)0); printf(“Done.n”); exit(0); } Running it, I have this result: ./badterm ‘unlisted’: unknown terminal type. According to setupterm function definition, it must return 0: “No matching entry in terminfo database”. Instead of this, program terminates. Why? Answer

Advertisement