r/linuxdev • • Dec 17 '22

How to create a flatpak pakage of an application written in python with pyside6 and rust?

Thumbnail reddit.com
3 Upvotes

r/linuxdev • • Nov 19 '22

How can I send CLI commands to a service in the background

3 Upvotes

I am building an app that will run in the background as a service.

However I cannot figure out how to send commands from the CLI. I've looked into DBus while it does work, it doesn't seem to be the way any other apps/services does it.

For example I've launched the `dbus-monitor`, and ran a bunch of commands to `netstat`, `nftables` etc. And none are using DBus. So what are they using to communicate with the service running in the background?

I would like to send commands such as: `customappname refresh`, `customappname add 'something'` and so forth.

I'd like this to work on as many linux operating systems as possible.

Any info would be great. Thanks.


r/linuxdev • • Aug 24 '22

How to add destructive flag to fsck.exfat that will allow proper repairs (deleting corrupt files)?

3 Upvotes

Fsck.exfat (both the built in one on Ubuntu and the one you get if you install exfat-fuse, assuming they're different) don't seem to be capable of repairing the most common corruption I'm experiencing on ExFAT filesystems.

Every time an ExFAT filesystem breaks (or at least, most times) it's due to a failed file copy resulting in this error during fsck.exfat with any flags:

ERROR /file/location/filename.ext first cluster is wrong. Truncate (y/N)? N

There doesn't seem to be a way to force it to actually fix those files, as it enters "n" for you every time. I've tried every flag available in --help, including the ones that say they will automatically repair it. Even the interactive flag fills in the no response for every file, and isn't in any way interactive.

I'm assuming this is just a poorly worded way to ensure that data isn't accidentally deleted, but what would it take to get a Force override option that actually address the files, and removes them? When I delete the files manually (it lists all the files) fsck reports the filesystem is fine, and I'm able to use it again.

Or is this a bug I should just file a bug report for?

The error:

Files corrupted 5, files fixed 0

Fsck from version util-Linux 2.37.2 Exfatprogs 1.1.3

Ubuntu 22.04.1


r/linuxdev • • Aug 17 '22

does anyone know of a lightweight Windows sandbox

3 Upvotes

WSL is a thing, but I'm not a big fan of Windows. Does anyone know of a lightweight Windows sandbox that can perfectly emulate windows?


r/linuxdev • • Jun 03 '22

What are the considerations for developing for multiple distros?

3 Upvotes

What are the considerations for developing for multiple distros?

Particularly:

  • How compatible are different distros with each other?

  • How do I know when things are compatible?

  • How do I ensure compatability?

  • What about rolling-release vs fixed release distros?


r/linuxdev • • May 18 '22

Rough estimate on work involved to get linux camera driver written?

3 Upvotes

This is with regard to the Pinephone Pro which at this time still does not have working cameras.

Apparently they loaded up an Android image to make sure they worked physically.

I'm just curious "abstract/high level" what kind of work is involved to get that done.


r/linuxdev • • Mar 22 '22

Why might a call to sem_wait cause a thread to exit?

3 Upvotes

I can't share my exact code as it's work specific, but I've run into an absolutely baffling issue.

Let's say I have a codebase that looks like such:

#include <semaphore.h>

typedef Queue_s Queue_t; //Arbitrary struct

//The actual code deals with queues, so I've stuck with that example here
struct Queue_s{
sem_t sem;
//Other, currently unimportant queue functions
};

static Queue_t g_queueContainer[NUMBER_OF_QUEUES]//Static list of queues for the 
                                                 //current process
static uint32_t g_containerIndex;
static sem_t    g_libraryMutex;

void Queue_Library_Init()
{
    sem_init(&g_libraryMutex, 0, 1); //Semaphore is for the current process only, 
                                     //size of 1
    (void)memset(g_queueContainer, 0, sizeof(Queue_t) * NUMBER_OF_QUEUES);
    g_containerIndex = 0;
}

void Queue_Do_Stuff()
{
    //Assume that queue is NOT NULL. In real code I would assert
    sem_wait(&g_libraryMutex)
    
    //access the static list of objects
    //Assume this function neither waits, nor has infinite loops.
    //(i.e. its number of operations is FIXED)

    sem_post(&g_libraryMutex);
}

Now, let's assume that Queue_Library_Init() is called ONCE in the main function, and Queue_Do_Stuff() is called an indeterminate number of times. Also assume that semaphores are NEVER destroyed, and once a queue has been allocated and g_containerIndex is incremented, it can never be deallocated or decremented. Once a queue is created, its existence in memory is FIXED.

Eventually, some nth call to Queue_Do_Stuff() causes my running thread to exit with an exit code of zero and no errors. It exits on the call to sem_wait().

Upon running strace on my program, I can see that the very last system call that is made is

futex(/*arbitrary value*/, FUTEX_WAIT_PRIVATE, /*arbitrary value/).

and then exit(0). Several of my more senior coworkers and I have stepped through the code and are completely baffled.

We're trying to port our existing codebase to POSIX, and we're using Ubuntu 20.04 for testing (This is an embedded, avionics use case, so every object that we create in memory we LEAVE in memory for determinism)

Without the actual codebase, I know this is impossible to debug...But would anyone with more experience with Linux system calls have any advice to push us in the right direction?


r/linuxdev • • Feb 19 '22

Linux kernel mailling list

3 Upvotes

How do I access the linux kernel mailing list and find work to do on the kernel


r/linuxdev • • Jan 30 '22

Enabling KVM without BIOS setup

3 Upvotes

I'm running Debian 11 LXDE in an old notebook and during the boot I'm receiving the following message:

root@debian:~# dmesg | grep -i kvm
[   20.501228] kvm: disabled by bios
[   20.541824] kvm: disabled by bios

Also, when I try to create a VM in virt-manager, I get the following message:

Warning: KVM is not available. This may mean the KVM package is not installed, or the KVM kernel modules are not loaded. Your virtual machines may perform poorly.

And indeed the VM performs very poor.

However, I'm pretty sure the processor is capable of virtualization:

root@debian:~# lscpu | grep -i "virtualization\|svm"
Virtualization:                  AMD-V
Flags:                           fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ht syscall nx mmxext fxsr_opt pdpe1gb rdtscp lm constant_tsc rep_good nopl nonstop_tsc cpuid extd_apicid aperfmperf pni monitor ssse3 cx16 popcnt lahf_lm cmp_legacy svm extapic cr8_legacy abm sse4a misalignsse 3dnowprefetch ibs skinit wdt hw_pstate vmmcall arat npt lbrv svm_lock nrip_save pausefilter

Unfortunately, the BIOS setup is very simple and doesn't have any option of virtualization to be set. Therefore, I can't enable the virtualization via BIOS setup.

Question

Is it possible to enable KVM by other means instead of BIOS setup?


Hardware Specification

 

root@debian:~# dmidecode | grep -i "version\|release"
	Version: V2.12
	Release Date: 04/16/2013
	Version: V2.12
	Version: Type2 - A01 Board Version
	Version: Chassis Version
	Version: AMD E1-1200 APU with Radeon(tm) HD Graphics

r/linuxdev • • Nov 10 '20

Mixing multi-processing and multi-threading

3 Upvotes

Introduction to My Issue

I'm developing a general purpose library in C++. One of its features is periodic run of various commands - on startup the library reads a configuration file with "jobs" to execute with time intervals, and it executes them.

In the current implementation, on startup the library creates it own thread which mostly sleeps, checking if its time to run a command. This was done to avoid forcing the consumers of the library to call it once-in-a-while.

Unfortunately, we found out that one of the teams that consume the library use it in some service with workers - it forks multiple times on startup, and its worker processes preform most of its logic.

The Issue

According to the internet and man documentation, mixing multiprocessing and multithreading is hard. Quoting fork's man page:

After a fork() in a multithreaded program, the child can safely call only async-signal-safe functions (see signal-safety(7)) until such time as it calls execve(2).

As I have no control on the host process, my library breaks it in the sense that it is now a multithreaded program instead of a single-threaded program, causing the child to run invalid code.

Moreover, the man page suggest:

the use of pthread_atfork(3) may be helpful for dealing with problems that this can cause.

As pointed out in various posts and stack-overflow, pthread_atfork should cause the run of handlers which are supposed to help to clean things related to multi-threading, but it actually cannot do so! Functions like pthread_mutex_lock are not signal-safe, and it is not entirely clear if one can unlock the mutex from a different process from which it was locked:

Attempting to unlock the mutex if it was not locked by the calling thread results in undefined behavior

My questions

Assume I understand thoroughly the issues with mixing multi-processing and multi-threading.

  1. Assuming my use-case, can I somehow fix the above issue without making my library fork instead of creating a thread, or forcing my consumers not to fork?

  2. What happens in practice? Does glibc (or any other common libc) uses pthread_atfork to protect its internal mutexes? (malloc mutex, dynamic loader mutex)

  3. In general, is there a way to mix multi-processing and multi-threading? Are there any common C++ patterns to maintain some sense of safety? (mutexes are unlocked, file descriptors are closed...)

References

Various posts and threads I've read and related to this issue:

https://stackoverflow.com/questions/6056903/multithreaded-fork https://stackoverflow.com/questions/2620313/how-to-use-pthread-atfork-and-pthread-once-to-reinitialize-mutexes-in-child https://groups.google.com/g/comp.programming.threads/c/ThHE32-vRsg https://www.linuxprogrammingblog.com/threads-and-fork-think-twice-before-using-them


r/linuxdev • • Mar 21 '20

GitHub actions: libGL error: No matching fbConfigs or visuals found

3 Upvotes

Hi all,

I’m currently working on adding GitHub Actions support to a project of mine that is using SFML (which uses OpenGL under the hood). I’m only using the `ubuntu-latest` (Ubuntu 18.04) runner for now to keep things simple. The runners for these actions are headless so I’m running with Xvfb.

I consistently get the following errors:

libGL error: No matching fbConfigs or visuals found
libGL error: failed to load driver: swrast

I’ve done a bit of research into this and I’ve seen that this can be caused by ambiguous references to libGL.so, but I don't see duplicates of libGL. I’ve tried updating mesa and get the same issue. I’ve also tried renaming the ligGL.so files as recommended here but that had no effect.

Here is a project that shows a minimum reproducible case.

Here is the setup code from that project.

Am I missing something here? Does anyone have any ideas? Has anyone got any gui application to work with GitHub Actions (or with a similar headless setup)?


r/linuxdev • • Feb 02 '19

How do I do publishing/subscribing across apps on linux?

3 Upvotes

Lets say I have have one app that's a publisher and 0 or many subscriber apps. How do I tell subscriber apps when an event occurred? The best I can come up with is to write to a log file and have subscribers watch the file. I haven't done files for a while so I don't remember, how do I create a file that isn't read exclusive? and how does the subscribing app know when I write to it? Does it have to use something like inotifywait? On windows you can send events to other apps, can I do that on linux?


r/linuxdev • • Dec 21 '18

Linux USB boot

3 Upvotes

I posted this to /r/linuxquestions first but this subreddit seems more appropriate, so I'll repost here

Hello! If this is the wrong subreddit, please let me know. Thanks!

I've been working on making my own Linux distro from scratch, mostly for fun, but also to see if I can innovate a little by shedding a lot of the cruft of the old ways (traditional package management, old architectures, BIOS boot, 32 bit, etc). Think of it as NixOS that feels like a normal distro or as Fedora Silverblue but without the legacy of RPM.

I'm trying to boot the system, and it will not find the boot medium (USB drive) to mount a rootfs. The EFI finds the kernel and the initramfs without issue, but once the kernel is executed, USB completely shuts down. Systemd blocks while waiting for the rootfs to show up, and eventually times out and Dracut drops me to a root shell in the initramfs. Since USB isn't working I cannot type anything on this shell to investigate further, since my keyboard also works through USB. I don't have a PS2 keyboard or port to use

The flash drive's partition table is configured like a normal HDD. I have a vfat ESP and an ext4 rootfs. I get the same result if I provide a root= argument on the kernel command line, or if I let systemd use GPT to figure it out automatically. My initramfs is assembled using Dracut. The init in the initramfs is systemd. Linux version is 4.19.1

I've been trying to mess with the Linux config, since I suspect I'm not loading some USB driver. I'm not having much success, and I've even copied Arch's kernel configuration and am still having the same issues. As soon as the kernel is executed, I see the USB activity light on my drive go off (it pulses if the drive isn't being accessed but it has power) and it never comes back on again. Different USB ports all have the same result.

Am I looking for a solution in the right place? Does this sound like a misconfigured kernel or some other issue? (maybe Dracut is misconfigured and needs something special for booting off of USB?)

Crummy picture of the initramfs

Thanks and happy holidays!


r/linuxdev • • Apr 30 '18

GraalVM

3 Upvotes

Has anyone played around with Oracle's new GraalVM? If so, what do you think?


r/linuxdev • • Apr 24 '18

Creating a graphical element to display sensor data

3 Upvotes

I wish to build a graphical interface element that would change with correspondence to input data. It would be similar to the battery icon on the phone which "fills up" according to the battery level or a "system monitor widget" that displays an icon that corresponds to the current CPU usage etc. I know that usually for battery, volume or CPU levels there are about five or so icons where the one with the single bar corresponds to 0%~20%, three bars to 60%~80% and so on, so there aren't many icons to deal with. However what if I want the text to go on top of the icon? I would need to have 100 different images. I hope to eventually incorporate this icon to the status bar of my PC.

I'd prefer it to be a vector drawing, so that it could be scaled or change colors easily. My first thought was to build a program that would grab the input data and draw the icon using cairo. It needs to constantly refresh. Grabbing data, generating and drawing the icon every second or so. Another option is to make the list of icons into a font that consists of about a 100 or so images.

Is this a feasible approach? Is it efficient? Is there a better way to achieve this?


r/linuxdev • • Feb 19 '18

Ensuring a safe PATH for system() in a root-setuid'ed program?

3 Upvotes

I am making a C++ program, intended to have its setuid flag on and owned by root, which needs to call system(). I am worried, however, that a malicious user could set their PATH so that the programs I call as root are instead replaced with their own.

Is there some way to ensure a standard PATH of /usr/bin, /usr/local/bin, etc. for system() function calls?


r/linuxdev • • Nov 09 '17

Question on customizing gTK-2 themes [crosspost from r/gTK]

3 Upvotes

I use Terminator (terminal) which allows me to divide the window horizontally/vertically into multiple sub-terminals. There's a setting to adjust the separator size but I've found it only works for certain themes, while others only show the separator with single-pixel width. More specifically in Theme Manager it's the Controls section that must contain the specific code-segment. BlackMATE and Xfce-dusk do show the separator size as specified in terminator, while Adwaita-dark and Axiomd do not. One specific theme "05-Crunchy-green" seems to glitch in a way I actually really like - it shows the separator as a transparent gap! I'd guess it's trying to overlay a graphic that doesn't exist.

The separator not working in Terminator had been reported as a bug, but was patched with these changes.

I dug through /usr/share/themes/<theme>/gtk-2.0/gtkrc and ~/.themes/<theme>/gtk-2.0/gtkrc and tried to work out exactly what the code/variable/declaration is, but I don't have nearly enough experience on this level. Best I can tell it should be GtkPaned::handle-size, but adjusting that variable doesn't seem to change the separator size.

Can anyone explain what the relevant variable is, the basics of how this works, or point me towards a relevant resource?


r/linuxdev • • Oct 27 '17

Compiling a single, in-tree kernel module, not set originally in .config. help

3 Upvotes

As the title explains, I've been trying to compile a kernel module. I've been trying to use the usual stuff: "make -C /lib/modules/$(uname -r)/build M=$PWD modules", but I've realized that if such module wasn't set to be compiled on that kernel originally,make will skip it, even though I changed the .config file to set it as a module. Look, I know this is a noob question, but if anybody has 5min to reply and help me out, it'd be awesome.


r/linuxdev • • Aug 22 '17

[Help] Resources on scheduling

3 Upvotes

Hi all,

I will soon be working on the CFS for a project at my uni.

I'm currently gathering all resources I can find on scheduling, I have some experience with it but only on single CPU scenarios.

It can be about CFS or scheduling in general, it does not matter as long as it is somewhat recent (Professional Linux Kernel Architecture is outdated when it comes to scheduling with SMP).

Any ideas ? All suggestions are welcome, thank you in advance !


r/linuxdev • • Jun 26 '17

How to write a custom desktop environment

3 Upvotes

I'm looking to write a custom DE for linux. I want something like a media browser: display the icon, meta data for the movie story line, and the ability to play from the selection. Restricted access to system specific files; only media can be browsed and played.

I have years of experience programming and minor OS writing experience in uni.

What do I need to get started?


r/linuxdev • • Sep 19 '16

Block Device Development Tutor?

3 Upvotes

Can someone refer me to an experienced Linux kernel developer who might be willing to teach me the finer details of implementing high performance Linux block devices?

I'm willing to pay a kernel dev to teach me over Skype, taking me through existing block device code such as: https://lwn.net/Articles/58720/ and linux/drivers/block/loop.c

I ultimately want to develop a block device that works somewhat like loop.c, but instead of the target being a filesystem image file, the target is a user mode process that manages the filesystem image (and can now provide instrumentation, encryption, etc). Does something like this already exist?

I am a decent C/C++ developer and Linux user with zero experience in kernel development.


r/linuxdev • • May 14 '16

Syncing aliases between Linux systems

3 Upvotes

As a student, or general Linux user, I find myself logging into multiple Linux systems. Over the years I have acquired useful aliases from professors, and some that I have personally added. I am thinking of creating some software, that could become a staple to the Linux environment, that would provide the syncing of aliases across multiple Linux systems.

It would, of course, deal with differing shell types, (csh, tcsh, bash, zsh, etc.), and would be able to convert between each type's own alias syntax.

More details on the features planned, are here on my github account: https://github.com/Proryanator/als

Some aliases can cut your use time in half, or even more. As much as some people find aliases to be a crutch for avoiding proper syntax, I disagree. I find myself typing the same combination of commands more often than not, so aliases are a must have for productivity.

I am curious, would this be something that other linux developers would find useful?

If there is something useful that already exists, please tell me! Or if as developers, this would be something you'd be interested in seeing get created, also good to hear! Any feedback is much appreciated!


r/linuxdev • • Jan 15 '16

[kernel] adding a controller to xpad.c?

3 Upvotes

So I have an old psx to usb controller that, while it works as a regular generic joystick device, I'd like to add to xpad.c in the linux kernel. I'm using Arch so I've been following the guide to compile specific modules. However, I cant seem to get it to work when I add it in the xpad module.

My USB device reports this info with lsusb.

I've tried adding the following line in my xpad.c file:

	{ 0x6666, 0x0667, "WiseGroup Smart Joy PSX, PS-PC Smart JoyPad", 0, DANCEPAD_MAP_CONFIG, XTYPE_XBOX },

which then looks like this. I then began gzipping and copying over the compiled module as per the guide. Yet the xpad module does not auto-load on reboot. dmesg and journalctl dont appear to throw any errors. modprobing xpad doesnt seem to map the joystick axis as buttons as I've requested it to do.

What am I doing wrong? I'm very new to building kernel modules. Have I named the usb device wrong is xpad.c?


r/linuxdev • • Dec 10 '15

syslog vs. rsyslog

3 Upvotes

Searching the internet for the difference between syslog and rsyslog gives quite a few results geared towards system admins, not for application developers. So, I'm coming to you people for help!

Setup: I am using Ubuntu 14.04 for my applications (building and running natively). When running this command:

ps -aux | grep syslog

I see these two processing running:

/usr/bin/pulseaudio --start --log-target=syslog
rsyslogd

Is my system using rsyslog instead of syslog? Can one/ should one run syslog and rsyslog at the same time? It still looks like my application logs are being written to /var/log/syslog.

From an application running on my system is an openlog(...) system call opening rsyslog instead of syslog? How do I know this?

As you can tell I'm kind of a noob so any extra info you can think of would be appreciated.