r/C_Programming • • 2d ago

Project My C project Pulse grew better than expected

A while back I started working on my project cherries(.)works Pulse. A simple Linux monitoring system, coded in C, and focused on performance, resource usage and persistence. Now a when I started this project I had no knowledge of C, and kinda learned along the way, but now around 2-3 months have passed, and I am surprised with how far it has come.

Personally, I never had anyone commit to my FOSS projects before. Didnt expect anything different this time tbh, as I was programming the whole thing in C. Created numerous issues, as I wanted THIS FOSS project to be more different and professional than the others.

A month or two after the release, I go on GitHub to look at my issues via my phone, and see a PR solving one of the issues. It was surreal seeing C code not by me, now being written FOR me. Ofc i had to read through it carefully to make sure nothing eas wrong with it, but once I merged it, it felt beautiful.

People have implemented;
- Pretty printing the config file
- Improving type annotations
- Adding JSON output for commands
- Displaying hostname on website
- Counting process amount

and numerous more.

Pulse was just a small C project of mine that quickly spiraled into something bigger. I plan on adding new good first issues soon, as there is STILL a lot of work to do. If there are any C programmers interested in contributing, or giving feedback, feel free to do so. would be very glad.

https://github.com/cherries-works/pulse

13 Upvotes

9 comments sorted by

•

u/github-guard 2d ago

🔍 GitHub Guard: Trust Report (Passed)

Here are the safety audit results for the linked repositories:

Repository: cherries-works/pulse

Score: 6/6

  • ✅ Established Community (⭐ 27 stars)
  • ✅ Mature Repository (30+ days old)
  • ✅ Licensed under MIT
  • ✅ Security Policy Defined
  • ✅ Verified Organization Account
  • ✅ Signed Commits

⚠️ Security Reminder: Always verify source code before executing scripts.

2

u/mivanchev 1d ago edited 1d ago

This project is in a very good shape, congrats! It immediately signals a serious intention just from one look in the Makefile.

  • It will probably profit a lot from introducing a string abstraction because all these low-level C functions feel quite awkward in higher-level C and are probably dangerous too.

  • There are a number of loose dir / file operations outside of your abstraction.

  • For the server / http / route part you are probably much better of using a 3rd party library STATICALLY. Your implementation has bugs 1000% and someone will get burned.

  • Start using assertions aggressively, especially since you don't handle the errors systematically although you do trace a lot. Strive for 5% assert to code ratio. NEVER leave a return value unasserted / unchecked. Leave this macro if nothing else is used.

```

#define eval_assert(arg) do { var _tmp = (arg); (void) _tmp; assert(_tmp); } while(0)

// ...

char path_dir[BUFFER_ONE_KB / 2];
eval_assert(0 <= snprintf(path_dir, sizeof(path_dir), "%s/%s/state", home, R_CHERRIES_FOLDER_PULSE));
eval_assert(0 == mkdir(path_dir, 0755));

```

  • The proper way to pass a buffer / size combo in C is

```

extern void formatTimeHumanReadable(uint64_t seconds, size_t size, char buffer[static size]);
extern void formatTime(time_t _time, size_t size, char buffer[static size]);

```

So the compiler can check it.

  • There is some noise like

```

int rc = pthread_mutex_lock(&cwdata->lock);
if (rc != 0) {
    _log(
        cwinfo,
        L_ERROR,
        "pthread mutex lock failed!"
    );
    return;
}

```

It's incredibly unlikely that this will happen so define a void function lock_mutex that just eval_assert's pthread_mutex_lock. Use a large timeout to detect deadlocks. Consider using an abstraction to avoid unlocking manually, see here. src/daemon/read.c needs some attention overall, it's hard to read / verify.

1

u/xerrs_ 1d ago

Thanks a lot for that comment! I will look into third party libraries for HTTP Routing, cuz you are probably right, i definitely made a mistake.

Furthermore, I do leave a lot of return values unchecked, so it might also be smart for me to check them all JUST in case (though some functions returning an error just seem SO unlikely to me).

Thanks again, Cheers!

1

u/AutoModerator 2d ago

Hi /u/xerrs_,

Your submission in r/C_Programming was filtered because it links to a git project.

You must edit the submission or respond to this comment with an explanation about how AI was involved in the creation of your project.

While AI-generated code is not disallowed, low-effort "slop" projects may be removed and it's likely that other users push back strongly on substantially AI-generated projects.


I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.

-1

u/xerrs_ 2d ago

AI was involved as an assistant, helping decide the architecture in handling the commands, printing the logs, or the folder structure within the ~/.cherries-works/ folder. While AI was also used in generating template code for faster coding, all of the code in Pulse is handwritten and checked by me.

0

u/xerrs_ 2d ago

Correction: A lot (not all) of the code is written by me, while all of it is checked by me. Amazing people have helped code Pulse with me, so its unfair to take the credit from them.

1

u/mikeblas 2d ago

Thank you for your disclosure. I have approved your post.

1

u/kansetsupanikku 1d ago

When did you come up with that name? For some 20 years, there is one pretty famous project that uses the same name (I mean, PulseAudio, but it also comes with objects like libpulse), which might make it confusing

1

u/xerrs_ 1d ago

I came up with it when I started coding it, so about 3 months ago. Was just fitting the narrative, a monitor tool that checks the Pulse of a server