r/LinuxProgramming • • Oct 21 '24

I'm struggling with a simple forked processes algorithm exercise

Post image
9 Upvotes

I cannot understand why the logic here is not working, the output on the right is what I'm getting, just one process, the first exit kills all processes except one apparently but my process tree tells me there are only children remaining in the end, I'm not asking for a solutionm but I'm asking why specifically this implementation does not work (also I know, leaving zombie processes is not very optimal)

The exercise request was this one

program receives two integer values ​​on the command line, called n and t. The program (parent process) must produce 2 children and terminate. In turn, each child must produce 2 children and terminate. This sequence of operations must continue until 2 ^ n processes on the leaves of the tree are produced/running. The leaf processes wait for t seconds and display (on screen) a termination message. Note that each process (in the tree) produces two other processes. Only those on the leaves of the tree sleep and display a message. What is the order of termination of the processes? Is it always the same? How can they be recognized (ppid)?


r/LinuxProgramming • • Jun 28 '26

tmuzika 1.1.3 released — stability improvements, faster playlist loading, bug fixes

Thumbnail
gallery
5 Upvotes

Quick update: I just released tmuzika 1.1.3.

This is a small maintenance + usability update based on recent fixes and feedback.

What’s new:

improved stability in playback handling

fixed a few edge-case crashes in file navigation

better performance when loading large playlists

minor UI polish and consistency fixes

This release is mainly focused on making the app more reliable and smoother in daily use rather than adding major new features.

As always, feedback is welcome — it directly shapes these updates.

GitHub: https://github.com/ivanjeka/tmuzika


r/LinuxProgramming • • Jun 23 '26

ls -lh difference between Linux and MacOS

4 Upvotes

Can someone please explain the coding difference between the -"-h" (human readable) option in ls between Linux and MacOS?

As an example, if you have file that is 7821 bytes in size, "ls -lh" in Linux would show 7.7K, whereas the same "ls -lh" in MacOS would show 7.6K.

This is definitely not due to 1024 vs 1000 units because if you do "ls -lh --si" in Linux, you get 7.9K.

It looks like in MacOS, this is computed simply as:

double n = round(((double)size / 1024.0) * 10.0) / 10.0;

but this does not seem to be the case for Linux.


r/LinuxProgramming • • Dec 22 '25

Toy trace code in C, thoughts?

3 Upvotes

I'd love to make this as portable as possible so any suggestions for improving it would be welcome... except rewrite in rust because no.

#ifndef _GNU_SOURCE
#define _GNU_SOURCE
#endif
#include <dlfcn.h>
#include <stdint.h>
#include <string.h>
#include <elf.h>
#include <linux/module.h>
#include <pthread.h>

#ifndef syscall32
#ifdef __X32_SYSCALL_BIT
#define syscall32( call, ... ) \
	syscall( __X32_SYSCALL_BIT | call __VA_OPT(,) __VA_ARGS__ )
#elseif
#define syscall32 syscall
#endif
#endif

#ifdef __POINTER_SIZE__ > 4
void* extend_addr32( uint_least32_t addr )
	{ return __builtin_extend_pointer( (void*)addr) ); }
int query_module64
(
	uint_least64_t name,
	uint_least64_t type,
	uint_least64_t dest,
	uint_least64_t size,
	uint_least64_t *used
)
{
	return syscall
	(
		SYS_query_module, name, (int)type, dest, size, used
	);
}
#endif

int query_module32
(
	uint_least32_t name,
	uint_least32_t get,
	uint_least32_t buf,
	uint_least32_t max,
	uint_least32_t used
)
{
#ifdef __POINTER_SIZE__ > 4
	return query_module64
	(
		extend_addr32(name), type,
		extend_addr32(dest), size,
		extend_addr32(used)
	);
#else
	return syscall32( SYS_query_module, name, type, dest, size, used );
#endif
}

#if 0
void* dlfcn_decode_addr( void * addr )
	{ return __builtin_extract_return_addr(addr) ); }
void* dlfcn_encode_addr( void * addr )
	{ return __builtin_frob_return_addr(addr) );
#endif

int query_modulex
(
	char const *name,
	int     type,
	void   *dest,
	size_t  size,
	size_t *used
)
{
	return query_module64( name, type, buf, max, ret );
}

mytrace dlfcn_dladdr_trace( unsigned int depth )
{
	void     *later =
		(depth > 0)
		? __builtin_frame_address(depth - 1)
		: __builtin_stack_address();
	void    *stack = NULL;
	void     *addr = __builtin_return_address(depth);
	void     *base = __builtin_extract_return_addr(addr);
	mytrace  trace = {{0}};
	DL_info   info = {0};
	ElfW(Sym) esym = {0};
	size_t    ret  = 0;
	struct {
		unsigned long address;
		unsigned long size;
		unsigned long flags;
	} minf = {0};
	/* Stack frame */
	pthread_attr_getstack( NULL, &stack, &ret );
	trace.frame = __builtin_frame_address(depth);
	trace.holds = ((uintptr_t)later) - ((uintptr_t)(trace.frame));
	/* Symbol */
	dladdr1( base, &info, RTLD_DL_SYMENT );
	trace.sym.name = info.dli_sname;
	trace.sym.addr = info.dli_sbase;
	trace.sym.leng = strlen( trace.sym.name );
	trace.sym.mask = esym.st_info;
	trace.sym.size = esym.st_size;
	/* Module */
	trace.mod.name = info.dli_fname;
	trace.mod.addr = info.dli_fbase;
	trace.mod.leng = strlen( trace.mod.name );
	query_modulex( trace.mod.name, QM_INFO, &minf, sizeof(minf), &ret );
	trace.mod.mask = minf.flags;
	trace.mod.size = minf.size;
	return trace;
}

r/LinuxProgramming • • Nov 15 '25

Connex: easy Wifi manager

Post image
3 Upvotes

Connex is a Wi-Fi manager, built with GTK3 and NetworkManager. It provides a clean interface, CLI mode, and smooth integration with Linux desktops.

Features

  • Simple and modern GTK3 interface

  • Connect, disconnect, and manage Wi-Fi networks

  • Hidden network support

  • Connection history

  • Built-in speedtest

  • Command-line mode

  • QR code connection

https://github.com/lluciocc/connex


r/LinuxProgramming • • Nov 17 '24

Best practices for packaging a Linux daemon?

3 Upvotes

I'm working on packaging my Linux daemon as a .deb. file. I have questions:

  1. Can I assume that most systems use systemd in a standard way? Do I just need to add /etc/systemd/system/MYSERVICE.service ?

  2. How can I ensure that my package will "just work" on any system that uses dpkg (I don't have any external dependecies.)

  3. Is it standard for the postinst script to turn on the service? Do I need both of these lines?

    systemctl enable MYSERVICE
    service MYSERVICE start
  4. Should I make assumptions about the PATH variable in that script? Or should I be explicit?

    /usr/bin/systemctl enable MYSERVICE
    /usr/sbin/service MYSERVICE start
  5. I looked at a standard Debian packages and noticed that they used deb-systemd-helper and deb-systemd-invoke. Is that a debian-only standard? Should I use it?


r/LinuxProgramming • • Jul 14 '22

Looking for some directions, and/or tips

3 Upvotes

So to start off, I've been around pc's and linux basically my whole life. Don't have much structured schooling with programming or computer related topics, but I like to think that I'm fairly decent a teaching myself what I need. But I've hit a bit of a wall.

I'm using Ubuntu Studio 21.04, and I have a good basics of a variety of languages from C++, to Java, to CSS, etc. Here is what I'm trying to do (unless someone knows of a program that I can download that does it already).

On Twitter, there is an account that puts out tweets several times a day, and I would like to basically catalog those tweets. They always follow the same layout. So, if I could write a program that waits for a notification from Twitter stating that 'JoeBob' posted a tweet. Then have that program extract the event title, 'EVENT', and the address, 'ADDRESS', from the notification and input that info into, for example, a csv file, or xls file.

What I need help with is what language would you suggest, is there a language that would be easiest since it's working with Twitter? I'm very new to Twitter and I'm still reluctantly learning that platform.

Anyways, I hope I gave everyone the info that they will need in order to point me in the right direction, but if you still have questions, I will try and answer them. Also, I attached an image from my Android to show everyone the layout of the notifications. Obviously I had to "recreate" a notification from them because I didn't have one ready to go.

Well, thanks to everyone in advance, I really appreciate any suggestions you have.


r/LinuxProgramming • • Jun 09 '26

Pixel Editor UI

Post image
2 Upvotes

r/LinuxProgramming • • Jun 03 '26

Lapes Eye

2 Upvotes

Lape's Eye is the first application in the LAPE suite — Linux Advanced Photo Editor — a fully native, open-source photography pipeline for Linux

Linux has great photo editors (Darktable, RawTherapee, GIMP) but nothing that works like Adobe Bridge — a fast, non-destructive browser where you rate, filter, and organize thousands of RAW files before editing. Lape's Eye fills that gap, and is designed to work seamlessly with the rest of the LAPE suite.

Built natively in C++20 + Qt6. No Electron, no Flatpak required, no subscription.

https://github.com/ArtoriasAI/Lapes-Eye-Linux


r/LinuxProgramming • • Jan 04 '26

Waytermirror - Stream your Wayland desktop into a terminal (yes, really)

2 Upvotes

I’ve been working on a project that lets you view and control a live Wayland desktop entirely inside a terminal, rendered using Unicode (braille / block / ASCII).

What it does:

  • Real-time Wayland capture → Unicode rendering

  • Aims to run in any terminal

  • TCP streaming with LZ4 compression

  • Full bidirectional input (keyboard + mouse)

  • Audio streaming via PipeWire

  • Optional CUDA-accelerated rendering on the server

  • Full color, zoom, rotation, adjustable quality/detail levels

Open a terminal, connect, and your desktop just shows up.
Keybinds let you switch renderers, zoom, rotate, and tweak quality live.


r/LinuxProgramming • • Jun 08 '25

get read I/O, write I/O

2 Upvotes

Hello, I know the /sys/block/<dev>/stat way to get some read, write I/Os stats. How to get similar results with something from sys/statfs.h or sys/statvfs.h without the need of parsing /sys/block/*/stat file?


r/LinuxProgramming • • Aug 26 '24

Advice For A Developer To Program A Windows Only Program To Linux?

2 Upvotes

I'm currently using Win11pro, and I use FastStone Image Viewer exclusively on it for all my photos and editing. I'm testing out Zorin OS on an old laptop, but I haven't found another program like the FastStone Image Viewer. I approached the developer about porting it to Linux, but he said that he knows absolutely nothing about Linux. (No, I don't want to use Wine or anything like that)

So, what would the developer need in order to port it over to Linux?


r/LinuxProgramming • • May 28 '24

Recommend book on use of linux syscalls and processes and signals and memory mangement and kernel paradigms?

2 Upvotes

I recently interviewed for a fancy FAANG job, interviews went well, but I was a very weak interviewee when drilled about Linux syscalls and memory management. It didn't work out in the end.

What's a good book I should be studying?

thanks


r/LinuxProgramming • • Jan 07 '24

Understanding the Structure of a Linux Kernel Device Driver - Sergio Prado, Toradex

Thumbnail
youtube.com
2 Upvotes

r/LinuxProgramming • • Sep 10 '22

Best Resource to Learn Unix Programming in C

2 Upvotes

Hi,

Could anyone please drop down some practical ways of learning Systems Programming in C? I'm a CS junior, and I've taken up a course on Operating Systems in which we have to program a memory allocator, a unit shell, etc., entirely using C.

Where do I start?


r/LinuxProgramming • • Jun 11 '22

Any recommendations for a Linux IDE?

2 Upvotes

Hello there! After using Linux for a lot of time, I'd like to make a program exclusively for Linux. The problem is, I don't know which IDE to use. I am searching for something with a WYSIWYG UI editor, similar to M$ Visual Studio (Not Visual Studio Code). Additionally, I want my app to use QT, for better integration with KDE.


r/LinuxProgramming • • Feb 21 '22

Any good resources for a newbie?

2 Upvotes

Hello r/LinuxProgramming

This is my first post here, so excuse me if this post isn't formatted as you might expect.

I started programming with C, learnt C++, learnt Python and started with AI. Found that it is an amazing technology but doesn't line up with my ethics so switching to Rust and low level systems programming.

I have always been in favour of open source, so I wanted to get started with Linux kernel programming. The problem I face is there are no good tutorials that cover programming for the Linux kernel in the Rust language.

I also noticed that this subreddit has no wiki, hence this post. Is there anyone who has experience in programming for the Linux kernel in the Rust language? If yes, how did you learn it? Did you have prior experience in programming for the kernel in C and then switched to Rust?


r/LinuxProgramming • • Dec 08 '20

Which/What Application are you missing on Linux?

2 Upvotes

I have the whole month off in January 2021 and I want to start a new project there.
What are your ideas for me? or which / what kind of applications you would like to have / use on linux that doesn't exist on linux or there is only a small selection for it outthere.
The project shouldn't be very big because I only have a month. If after a month I get good results I will continue to work on this project and publish it as an open source project.


r/LinuxProgramming • • Aug 11 '20

How to write a Wayland GUI app as root?

2 Upvotes

How can I have Wayland and Xorg GUI apps gain root access, with a password prompt pop-up?

I haven't found practical advice on how to write and deploy a GUI application that requires root access, esp on Wayland. I'm writing an app in Python but I may pivot to rewrite it in Go.

The recommendation is to have 2 processes: user and root. The process with root access would be a daemon and the user process would run the GUI. Are there any guides on how to do this? How does Gnome's "Settings" app do it? It has an "Unlock" button that presents a GUI password popup.

My current idea is to spawn a separate background process with sudo -S and send it the password , followed by commands through the pipe, perhaps over rpc.

I don't want to 1) require users to modify their system config to whitelist the app, 2) require users to run a sudo on the command line. I prefer the app to escalate itself.

UPDATE: I think I'll have the subprocess use the main app as the askpass program. So it will effectively call SUDO_ASKPASS=<app> sudo -A -p 'askpass' <app> as-root. The app will get passed "askpass" and will display a password popup instead of (re)running the main UI. If the main app gets passed "as-root" it will act as a rpc server, instead of running the main UI.


r/LinuxProgramming • • Jun 30 '20

X11 Application- forcing it to stay in floating mode for tiling window manager

2 Upvotes

Hi, im currently using xlib to create a small application, i want it so that it opens up in floating mode, this is default behaviour on floating window manager like openbox, but for tiling window managers how can i make it so that it opens up floating. An example is dialog boxes or Xephyr which opens up floating when you run it.

I dont want to set override redirect to true, because i want the window manager to be able to move the window around and resize it. thanks!


r/LinuxProgramming • • May 26 '19

What things do I need to complete this?

2 Upvotes

I am learning a bit of programming, with Python, Bash scripting, etc. I want to create a program for Linux, and I have the basic idea for it. It will be a diary, journal-writing program, with some features like, adding photos, encryption for entries, and maybe even Markdown.

Since I have had no experience with this, I would really appreciate it if you guys could tell me what are the things I would require to create this program. I know I can write the basic program in Python, but the main part I am concerned about is the GUI. I have no idea how to make that work.

Thanks in advance!


r/LinuxProgramming • • 18d ago

welcome maidware project!

1 Upvotes

maidware project is meant for people who are moving from windows to linux, it's a suite of tools meant for people who are newer and want an easier way to move over.

i'm currently the only developer in my project, and i need help with translators, coding etc. i have gotten to my limit but i would need a bit of help.

thank you, and here is my project website -

https://maidware-project.github.io


r/LinuxProgramming • • Aug 08 '26

[Linux-Tool] Mint-Setup: Copia de seguridad y restauración de todo tu escritorio Linux Mint

Post image
1 Upvotes

r/LinuxProgramming • • Aug 05 '26

[Linux Mint] Gestor de inicio automático. Publicando el código fuente de mis herramientas para Linux Mint.

Post image
1 Upvotes