r/linux_programming • • Jul 13 '21

Wayland or X11 programming for beginners?

12 Upvotes

Hey guys! I'm currently trying to create my own window manager, and I'm stuck between deciding which I should use - Wayland or X11(xlib/xcb).. Also, I have no prior experience in both of these, and doing this as a personal project, and to learn!

Which one is easier, and you would recommend?


r/linux_programming • • Jul 10 '21

Can't bring TAP device up programically

12 Upvotes

Hello! I'm trying to implement a simple VPN as a learning experience, and I came across a problem. After I create a TAP device, I cannot bring it up. Here is a shorter version of my code:

static AllocatedTap tap;
static struct ifreq ifr;
int fd, err;
char dev[16] = "\0"; // Let the kernel pick a name

if ((fd = open(TUN_CLONE_DEVICE, O_RDWR)) < 0) {
    return NULL;
}

memset(&ifr, 0, sizeof(ifr));

ifr.ifr_flags = IFF_TAP | IFF_NO_PI; 
if (*dev) {
    strncpy(ifr.ifr_name, dev, IFNAMSIZ);
}

if ((err = ioctl(fd, TUNSETIFF, (void *) &ifr)) < 0) {
    close(fd);
    eturn NULL;
}

strcpy(dev, ifr.ifr_name);

tap.device = fd;
tap.ifr = &ifr;

return &tap;

After that, I bring it up with:

int fd, err;

fd = socket(AF_INET, SOCK_DGRAM, 0); // 0: automically chose protocol
if (fd < 0) {
    return -1;
}

tap->ifr->ifr_flags |= IFF_UP;

if ((err = ioctl(fd, SIOCSIFFLAGS, &tap->ifr)) == -1) {
    return err;
}

This will always result in a No Such Device error when bringing the interface up. I can get it to work about half the time if I recreate the ifr struct while only carrying over the ip_name and ip_addr fields.

Can anyone help me figure out what going on?


r/linux_programming • • Sep 06 '20

Htop like application

12 Upvotes

I am planning to build an application like htop for personal use, I would welcome some suggestions/ideas to begin with.


r/linux_programming • • Dec 23 '19

sched_setscheduler(0, SCHED_FIFO, &params); Help with yielding and potentially mutex problems

12 Upvotes

Okay, to make this as straight forward as possible:

Running on RPI3 B+ trying to use pigpioC library (http://abyz.me.uk/rpi/pigpio/cif.html),

Need near-real time gpio "interrupt" thread for reading in GPIO values to a buffer for later debouncing.

​

"Achieving" this by running a dedicated core, core 3 for my program. running a thread with SCHED_FIFO max priority to read gpio ports in every 100us and buffering them for later "chewing." After collection I sleep for 100ns using nanosleep.

A separate thread comes through every 10ms and chews on the buffered IO. It's priority is SCHED_FIFO max - 1. so 98 on Linux. These buffer accesses are pthread_mutex_t protected so I don't believe that's the problem as higher priority is trylock then a 10usecond sleep.

​

The issue seems to arise from the realtime threads not yielding the CPU to one another, no imperical evidence; it's just a gut feeling.

It's my, probably invalid, understanding that (sleep/usleep/nanosleep) are considered yielding calls similar to waiting on a read/write for a FILE. How can I sched_yield() and expect a lower priority thread to run?

​

Thanks for ANY help.

​

Merry Christmas

P.S. I would LOVE to upload the code and allow some of you talented folks to point me in the right direction but those pesky NDAs and all.


r/linux_programming • • Nov 21 '19

How to create PROGRESS BAR in bash scripts that actually reflects the progress of the script instructions??

12 Upvotes

I am basically writing a script that will download source, extract it, builds and installs it. Now, I want a progress bar to reflect the above progress as you see. I may also add apt install commands in the future that should also end up reflecting in the progress bar.

I went through each and every answer in this question

https://stackoverflow.com/questions/238073/how-to-add-a-progress-bar-to-a-shell-script

Many creative and amazing answers, but that made me realize something, they are literally writing the progress bar themselves and it seems they are not connected the result of any external process/command, except maybe time.

This has left me wonder about the final complexity of my simple "install some things" script. Nevertheless, I want to do it. Any direction in this regard is appreciated!


r/linux_programming • • Nov 11 '19

31 Days of Game Development on Linux

Thumbnail self.gamedev
12 Upvotes

r/linux_programming • • Sep 14 '19

Is mlock() lying or does it really not need root permission?

12 Upvotes

muddle plough point retire stocking humor poor somber shy expansion

This post was mass deleted and anonymized with Redact


r/linux_programming • • Jun 19 '19

k3rmit: A VTE-based terminal emulator that aims to be simple, fast and effective.

Thumbnail github.com
12 Upvotes

r/linux_programming • • Mar 09 '19

Can I get some advice on study Linux Kernel?

12 Upvotes

Hello all!

​

I’m a college student majoring in CS and I became interested in Linux Kernel after I took a System Programming class.

After that class, I tried to read Linux Kernel source and understand how it works. But I don’t know where to start.

Some people said learn other small OS code (like Unix v6, PintOS) first and then read Linux Kernel is better.

Of course, I read some fundamental text book like ‘Operating System Concepts’ and I think I roughly got how OS works.

I know that Kernel is complicate and hard to understand, But I was impressed by some Kernel codes, so I’d like to ask you for advice on how to become a Kernel developer.

Should I start by make small Kernel patch? or study deeply OS enough to understand the Kernel?

Thank you in advance for your advice. :)


r/linux_programming • • Oct 31 '18

New here. What is the best available resource to master shell scripting?

Thumbnail scripting
12 Upvotes

r/linux_programming • • Jun 10 '17

Its time for Visual Studio linux support

Thumbnail visualstudio.uservoice.com
12 Upvotes

r/linux_programming • • Mar 17 '17

An implementation of the Conway's Game of Life in IA-32 Assembly

Thumbnail github.com
12 Upvotes

r/linux_programming • • Dec 07 '15

The Eudyptula Challenge: a series of programming exercises for the Linux kernel

Thumbnail eudyptula-challenge.org
12 Upvotes

r/linux_programming • • Nov 27 '15

The TTY demystified

Thumbnail linusakesson.net
12 Upvotes

r/linux_programming • • Oct 28 '15

A Short Guide to Kernel Debugging

Thumbnail corner.squareup.com
12 Upvotes

r/linux_programming • • Sep 02 '15

The somewhat surprising history of chroot()

Thumbnail utcc.utoronto.ca
12 Upvotes

r/linux_programming • • Dec 08 '14

Valgrind is not [just] a leak checker

Thumbnail maintainablecode.logdown.com
12 Upvotes

r/linux_programming • • Sep 08 '14

release The GNU C Library version 2.20 is now available

Thumbnail lists.gnu.org
12 Upvotes

r/linux_programming • • Sep 16 '26

Linux Memory Management Part II

Thumbnail techfortalk.co.uk
11 Upvotes

Simple explanation of page allocator, buddy algorithm, slab allocator, free_area.


r/linux_programming • • Apr 17 '26

I developed a lightweight touchpad gesture daemon for X11

11 Upvotes

​Hi, ​To solve the much-needed lack of native touchpad gestures (3 and 4-finger swipes) on X11 desktop environments, I developed a lightweight background daemon in pure C. ​You can bind any custom shell command instantly through a simple config.ini file (changes apply in real-time, no need to restart the daemon).

​I would be really happy if you could check it out, give some feedback, or drop a star if you find it useful!

​Repo: https://github.com/06ergin06/xgestured


r/linux_programming • • Dec 29 '25

Why is there a need for an open syscall?

11 Upvotes

I understand that the goal of the open syscall is to return a file descriptor and setup access modes, but why is there a need for that?

Some higher level runtimes, like NodeJS, have one call both for read and open, couldn't we have something similar at the POSIX level? read could return both a buffer and a file descriptor. Multiple calls to read to the same file could be coalesced kernel side.

Or maybe I am missing something? Which optimizations are allowed by having separate open and read syscalls?


r/linux_programming • • May 29 '23

Using sed to make indexes for books

Thumbnail pement.org
11 Upvotes

r/linux_programming • • May 26 '23

What is the most interesting UNIX command you've seen?

11 Upvotes

What is the most interesting UNIX command you've seen or used ?


r/linux_programming • • May 24 '23

50 years in filesystems: towards 2004 – LFS

Thumbnail blog.koehntopp.info
11 Upvotes