How to Write a Linux Daemon from Start to Finish!

แชร์
ฝัง
  • เผยแพร่เมื่อ 4 มิ.ย. 2024
  • Linux Daemons, Services, whatever you wanna call em. Let's make one! We're going to make a file event watcher with inotify that sends desktop notifications to the user.
    Multithreaded socket server tutorial: • How to Write a Socket ...
    Custom network protocol tutorial: • Implementing a Network...
    inotify man page: man7.org/linux/man-pages/man7...
    libnotify docs: developer-old.gnome.org/libno...
    archwiki notify: wiki.archlinux.org/title/Desk...
    rolexhound src: hoff.industries/files/rolexho...
    Editor: Kate (xoxo KDE)
    Colours: Dracula
    LSP Server: clangd
    Chapters:
    0:00 - Intro
    1:07 - What is our Daemon going to do?
    2:02 - Libraries and System Calls
    5:25 - Project Naming
    6:09 - Including Headers
    6:54 - Exit Codes
    7:45 - Shell Arguments
    9:22 - Sprinkling of Memory Management
    13:50 - Daemon Main Loop
    14:45 - File Events with Inotify
    16:00 - Blocking vs Non-blocking Operations
    17:05 - Initialising Inotify
    20:00 - Introduction to Bitmasking
    21:29 - What Filesystem Events can we monitor?
    22:07 - Watching a file with Inotify
    24:40 - Handling Inotify Events
    37:05 - Wiring it up to Desktop Notifications
    44:30 - Testing Desktop Notifications
    45:25 - Testing with Accessing an SSH Identity
    45:58 - Signal Handling and Shutdown Handling
    49:25 - Summary and Outro
  • วิทยาศาสตร์และเทคโนโลยี

ความคิดเห็น • 359

  • @dv_xl
    @dv_xl 4 หลายเดือนก่อน +142

    Yo fontsize too small dawg

    • @hoff._world
      @hoff._world  4 หลายเดือนก่อน +58

      Just use a magnifier application bro 🔍🔍

    • @2kadrenojunkiegaming655
      @2kadrenojunkiegaming655 4 หลายเดือนก่อน +28

      use something other than a tiny ass phone screen to watch a c programming tutorial dawg

    • @NaN_000
      @NaN_000 4 หลายเดือนก่อน +1

      Use magnifier dawg

    • @vaisakhkm783
      @vaisakhkm783 4 หลายเดือนก่อน +10

      @@hoff._world i am using a magnifier..
      but it cuts off your beautiful face....

    • @hoff._world
      @hoff._world  4 หลายเดือนก่อน +2

      @@vaisakhkm783 😳😳😳

  • @ProBarokis
    @ProBarokis 4 หลายเดือนก่อน +286

    why is tommy innit writing linux daemons

    • @hoff._world
      @hoff._world  4 หลายเดือนก่อน +53

      Secret second channel my brother

    • @TheoParis
      @TheoParis 4 หลายเดือนก่อน +2

      This was my exact reaction lmaoo

    • @M1szS
      @M1szS 4 หลายเดือนก่อน +1

      My first thought

    • @stumbling
      @stumbling 4 หลายเดือนก่อน +9

      tommy.init

    • @BillGallowglass
      @BillGallowglass 4 หลายเดือนก่อน +1

      Tommy SystemD

  • @mbakem
    @mbakem 4 หลายเดือนก่อน +19

    You are patient and easy to follow. Please please…whatever you do…keep this style. You rock!!

    • @hoff._world
      @hoff._world  4 หลายเดือนก่อน +5

      Appreciate it my friend will do

  • @ahmedabuharthieh579
    @ahmedabuharthieh579 4 หลายเดือนก่อน +20

    Great video. Perfect amount of being informative/educational without dragging your feet, and you come up with a practical piece of software by the end of it. Very well done, hope to see more from you!

    • @hoff._world
      @hoff._world  4 หลายเดือนก่อน +1

      So glad to hear you liked it mate. Cheers!

  • @datadi
    @datadi 3 หลายเดือนก่อน

    This was a cool video on daemons. I've been looking for good resources all morning and this was the best introduction to getting started with it all. Thanks for the video! :D

  • @charlesmoscofian4137
    @charlesmoscofian4137 4 หลายเดือนก่อน

    Dude, you just earned yourself another subscriber, nicely done! Keep it up.

  • @pentagrams2350
    @pentagrams2350 4 หลายเดือนก่อน +4

    very well made video from such a small channel. i can see you growing drastically in the future

    • @hoff._world
      @hoff._world  4 หลายเดือนก่อน +1

      It means a lot, appreciate it mate. I like your Uncle Iroh pfp

  • @c0d_0x16
    @c0d_0x16 4 หลายเดือนก่อน +1

    This is so helpful, I've been learning system programming recently. I've wanting to write a battery demon, thanks to you, I now know where to start.

    • @hoff._world
      @hoff._world  4 หลายเดือนก่อน +3

      How good, let me know how it goes!

  • @hazmat86
    @hazmat86 4 หลายเดือนก่อน +1

    Awesome video man. Learned a ton. You got another sub here. Love to see systems related C videos. Can't wait for more!

    • @hoff._world
      @hoff._world  4 หลายเดือนก่อน +1

      Systems programming is one of the coolest things to me. Glad you think the same!

  • @happygofishing
    @happygofishing 4 หลายเดือนก่อน +7

    Probably the best C video Ive ever watched.

  • @GabeSullice
    @GabeSullice 3 หลายเดือนก่อน +9

    The kids are gonna be alright

    • @hoff._world
      @hoff._world  3 หลายเดือนก่อน +2

      my generation aint ruined yet :D

  • @noah0822-sk4pk
    @noah0822-sk4pk 4 หลายเดือนก่อน

    clear explanation. easy to follow. good intro video in general. thanks for posting this!!!

  • @Albertux
    @Albertux 4 หลายเดือนก่อน +2

    Glad to see young folks using a real operating system

  • @eoussama
    @eoussama 4 หลายเดือนก่อน +1

    Your style is very informative. Kudos!

    • @hoff._world
      @hoff._world  4 หลายเดือนก่อน

      Glad to hear it!

  • @andjankowski
    @andjankowski 3 หลายเดือนก่อน

    You are doing great job, keep it up!

  • @ivankevamo
    @ivankevamo 4 หลายเดือนก่อน

    Thanks a lot! So glad I found out your channel.
    Keep it up, greetings from Brazil.

    • @hoff._world
      @hoff._world  4 หลายเดือนก่อน +1

      thanks for hosting that CS major in rio

  • @kathirvelgounder9673
    @kathirvelgounder9673 4 หลายเดือนก่อน +2

    Better than most professors out there, very easy to follow and listen too!

    • @hoff._world
      @hoff._world  4 หลายเดือนก่อน

      in 20 years I'll be one watch

  • @mozartmaia6333
    @mozartmaia6333 หลายเดือนก่อน +2

    I spent a few hours trying to solve the dependency problem that other people had in the comments. Apparently there are some dependencies that he uses in the video that other distros don't have by default. What I did was install these dependencies with "sudo apt-get install libgdk-pixbuf2.0-dev" and "sudo apt-get install libglib2.0-dev" and installed the libnotify dependency too, but I dont remember the command anymore. Then I ran the build command as follows: "gcc -Wall -pedantic -std=gnu99 -o build/rolexhound rolexhound.c $(pkg-config - -cflags gdk-pixbuf-2.0 libnotify) -lnotify".
    Also, I changed the $PKG_CONFIG_PATH environment variable, but I don't know if that helped in any way. It only worked like this on Ubuntu, I hope it works for you too!

  • @CuriousCyclist
    @CuriousCyclist 4 หลายเดือนก่อน +2

    Just discovered your channel. Really good stuff. (aside from the small font size)

    • @hoff._world
      @hoff._world  4 หลายเดือนก่อน

      I'm guessing small font size might become a running joke here

  • @p0xygen
    @p0xygen 4 หลายเดือนก่อน

    Randomly had this on my TH-cam homepage and it's perfect! Love this video.
    Definitely going to try and write some cute little dogs that'll watch my clipboard for some magic later!

    • @hoff._world
      @hoff._world  4 หลายเดือนก่อน +1

      Awesome glad to hear you've got some ideas :)

  • @michaelscofield4524
    @michaelscofield4524 4 หลายเดือนก่อน +1

    Great video man! About a month ago I wrote a daemon in Zig also using inotify, although just to be fancy and learn I decided to use io_uring instead of actively polling events.

    • @hoff._world
      @hoff._world  4 หลายเดือนก่อน

      that's awesome bro Zig looks like a sweet lang just haven't had the time to learn it. How does io_uring work without polling? Does it emit signals, events or something your program can write handlers for?

    • @michaelscofield4524
      @michaelscofield4524 4 หลายเดือนก่อน

      @@hoff._world You tell the kernel to do IO operations (read, write, readv, writev, etc...) and letting it do them when it has time and tell you when they're ready, making them asynchronous. In the end you only have to check if the "completion queue" has any items in it, if not, your application continues as normal. It's a little overkill for a little program like this but it was interesting getting to work with it.

    • @hoff._world
      @hoff._world  4 หลายเดือนก่อน +1

      @@michaelscofield4524 sick thanks for sharing. In essence then you're doing a non-blocking check somewhere in your main loop and if that turns negative your daemon does other work until it's ready. Which is useful for bigger daemons for sure, especially if networking is involved where it could potentially talk to others as well (we might be doing that sometime :)

  • @model.citizen.ps3
    @model.citizen.ps3 3 หลายเดือนก่อน

    hey thanx for the great video (subbed)! Been trying to get back into C ever since I was forced to adopt Java (OOP) to get thru my classes at uni (comp sci major) and this video was a great help. Looking forward to enjoying more of your content and seeing where you take this very cool channel 🙂 I do gotta say though... PLEASE make the font in your text editor bigger in future videos! It will make your content WAY easier to engage with going forward (especially for those of us who generally watch YT on a tv screen as opposed to a laptop screen). Anyways that's my only complaint tho - keep up the good work!

    • @hoff._world
      @hoff._world  3 หลายเดือนก่อน

      don't stress bro font size will be bigger on the next one! Interesting point about the TV screen, hadn't thought about that before. Thanks for the comment!

  • @mikereynolds1368
    @mikereynolds1368 4 หลายเดือนก่อน

    Defo enjoyed this. Good on ya!

    • @hoff._world
      @hoff._world  4 หลายเดือนก่อน

      Thanks mate appreciate it!

  • @briandepazdiaz
    @briandepazdiaz 3 หลายเดือนก่อน

    i love this content! thank u for blessing us

  • @mailoisback
    @mailoisback 4 หลายเดือนก่อน

    Great channel, deserves more subs.

    • @hoff._world
      @hoff._world  4 หลายเดือนก่อน

      Er well it certainly did that the last day and a bit. Thanks!

  • @sunk3rn
    @sunk3rn 4 หลายเดือนก่อน

    great tutorial, subbed

  • @cnyegun
    @cnyegun 4 หลายเดือนก่อน +2

    Just got recommended this channel today

    • @hoff._world
      @hoff._world  4 หลายเดือนก่อน +1

      Thanks for tuning in my friend!

  • @LBCreateSpace
    @LBCreateSpace 2 หลายเดือนก่อน

    Thanks for making this! :D

  • @8Trails50
    @8Trails50 4 หลายเดือนก่อน +1

    this video is insanely goated

  • @imagineabout4153
    @imagineabout4153 4 หลายเดือนก่อน +34

    Will watch this tonight in bed, high as a kite! Keep it up :D

    • @hoff._world
      @hoff._world  4 หลายเดือนก่อน +7

      A good way to watch it :D thanks!

  • @kianureeves2519
    @kianureeves2519 4 หลายเดือนก่อน

    not watching yet, but commenting to boost the algorithm. I'll give this a try in a bit!

    • @hoff._world
      @hoff._world  4 หลายเดือนก่อน

      whatever you did worked mate thanks a million :)

  • @rohitjacob803
    @rohitjacob803 4 หลายเดือนก่อน

    This was a really good video. It would have been nice if you had included the part where the daemon detaches from the parent shell and runs in it's own session, and all the logs being written to a separate file. It would also be fun to see how to integrate the daemon with systemd and allow it to be started or stopped from there

    • @hoff._world
      @hoff._world  4 หลายเดือนก่อน

      There have been a few requests for something like that. I may do a follow up in future :D

  • @soup4632
    @soup4632 4 หลายเดือนก่อน

    damn. only watched first five minutes and already got agitated and intrigued. will watch this for sure. like your delivery. any chance you have discord channel or smth? you seem like a great guy to talk with

    • @hoff._world
      @hoff._world  4 หลายเดือนก่อน

      Hey thanks! Might make a discord server if the channel grows and there's interest

  • @Wakizu
    @Wakizu 4 หลายเดือนก่อน

    utube algo in work, recommended your awesome vdo

  • @goonman1255
    @goonman1255 4 หลายเดือนก่อน

    Great video mate

    • @hoff._world
      @hoff._world  4 หลายเดือนก่อน

      Cheers goon man

  • @aryantirkey1744
    @aryantirkey1744 4 หลายเดือนก่อน

    Great got me interested planing on making my own

    • @hoff._world
      @hoff._world  4 หลายเดือนก่อน

      Glad to hear it write back with what you come up with!

  • @sahithvibudhi7471
    @sahithvibudhi7471 4 หลายเดือนก่อน

    Great video! Subscribed

    • @hoff._world
      @hoff._world  4 หลายเดือนก่อน

      Legend mate thanks!

  • @DUDE_mutagen
    @DUDE_mutagen 4 หลายเดือนก่อน

    KEEP POSTING THESE, VIDEOS LIKE THESE THAT ACTUALLY EXPLAINs ARE KINO

    • @hoff._world
      @hoff._world  4 หลายเดือนก่อน

      Thanks dude appreciate it, will keep it real

  • @Hellbending
    @Hellbending 4 หลายเดือนก่อน +1

    This cunts a legend bro, keep up the work cuzzy. Showing your knowledge without going through at 100x speed and still having a sense of humour and normality about ya
    (Sorry for bad language, am from Australia is normal here hahahaha😂😂😂😂)

    • @hoff._world
      @hoff._world  4 หลายเดือนก่อน

      Mate literally same dont worry about it ya dog. Cheers for your comment

  • @jamesdavis914
    @jamesdavis914 3 หลายเดือนก่อน +1

    TY for live coding C!

    • @hoff._world
      @hoff._world  3 หลายเดือนก่อน

      if u liked this video ur gonna have a fun weekend keep an eye out

  • @maritimers4sure
    @maritimers4sure 2 หลายเดือนก่อน

    Excellent. Thanks.

  • @lassebq1
    @lassebq1 4 หลายเดือนก่อน

    Hey, you can also use glib's gio component for file monitoring. glib is included with almost any linux system since it's a gtk dependency (and as you know gtk apps are very common)

    • @hoff._world
      @hoff._world  4 หลายเดือนก่อน

      True, and with this daemon if you have libnotify you also have GTK. Good note!

  • @RobSwindell
    @RobSwindell 3 หลายเดือนก่อน

    12:04 use strrchr(argv[1], '/'); to find the pointer to the last slash instead of a strtok() loop.

    • @benhetland576
      @benhetland576 3 หลายเดือนก่อน

      As long as you remember to ignore any trailing slashes first.

  • @underthemeow9478
    @underthemeow9478 4 หลายเดือนก่อน +2

    super cool video! i wish you could show us your customized KDE

    • @hoff._world
      @hoff._world  4 หลายเดือนก่อน +2

      Cheers for the video idea. Years and years ago I showed it off on r/unixporn but it may be time for an update :)

  • @pedrogabrielnogueira1068
    @pedrogabrielnogueira1068 4 หลายเดือนก่อน

    I like this. Pretty cool :v
    Edit: I'm a scholar in a research group and watchdog sounded familiar.
    Maybe youtube recommended this to me because of it. IDK.
    But anyway, thanks. Now ik what a watchdog is :v

  • @preetishamballi6988
    @preetishamballi6988 2 หลายเดือนก่อน +4

    You are running it as a regular shell process, can you please make a video on how to run it as actual daemon which can be controlled by systemctl command

  • @thomas-sinkala
    @thomas-sinkala หลายเดือนก่อน +1

    Earned a subscriber.

  • @illegalsmirf
    @illegalsmirf 4 หลายเดือนก่อน

    You're a clever young man!

  • @anantuongcong
    @anantuongcong 4 หลายเดือนก่อน

    the only problem is if you want a better tutorial vid u can change your font size to bigger bro. Appreciate your work bro. Keep up the good work

    • @hoff._world
      @hoff._world  4 หลายเดือนก่อน

      u got it boss, thanks

  • @bulverismo
    @bulverismo 4 หลายเดือนก่อน +1

    thanks, really cool

  • @johntully1414
    @johntully1414 4 หลายเดือนก่อน +1

    once the file is written, the inotify_event watch descriptor is changed, so furthur access or "alterations" of the file won't be notified. also would be neat that if the file were moved, it would show the path it was moved to. btw nice video, the channel will blow up at this rate

    • @hoff._world
      @hoff._world  4 หลายเดือนก่อน

      when I test it multiple modifications work fine, not sure what's going wrong for you. Thanks for your comment!

    • @ricardogodoy7337
      @ricardogodoy7337 4 หลายเดือนก่อน

      it happens to me too, not sure why

    • @johntully1414
      @johntully1414 3 หลายเดือนก่อน

      ​@@hoff._world your code from pastebin has the same issue. mayb some platform dependency? im on arch6.7.3+dwm with dunst notify daemon. watch descriptor is being set to IN_MOVE_SELF rather than IN_MODIFY upon modification of the file. i guess when modifying the file it interprets it as "moving" the file, on my system.

    • @hoff._world
      @hoff._world  3 หลายเดือนก่อน

      @@johntully1414I have actually noticed that if you use vim to edit it generates move events for some reason. Every other editor I've tested doesn't have the issue so no clue why

    • @johntully1414
      @johntully1414 3 หลายเดือนก่อน +1

      @@hoff._world yupp, that was it. looks like the vim/neovim saving mechanism uses "swap" or "temporary" files, so when you're modifying the file in the text editor it writes to the temp file (like a buffer) rather than the original file. Then when you :w the file, it renames that temp file to the original filename.. hence generating move events.

  • @martian0x80
    @martian0x80 4 หลายเดือนก่อน

    Uses kate? Absolute chad, you earned my like. I love kate as a replacement for nvim/helix.

    • @hoff._world
      @hoff._world  4 หลายเดือนก่อน

      kate is just too comfy

  • @woliveiraxs
    @woliveiraxs 3 หลายเดือนก่อน +1

    Pretty good man :) Thanks for the nice and well exaplained tutorial :)

    • @hoff._world
      @hoff._world  3 หลายเดือนก่อน

      dont sweat it!

  • @ninesninesnines
    @ninesninesnines 4 หลายเดือนก่อน +13

    bro is keeping up with the 10 new years resolutions

    • @hoff._world
      @hoff._world  4 หลายเดือนก่อน

      Bro u know we arent gonna quit after the first three weeks :DDD

  • @scumpascumpa
    @scumpascumpa 3 หลายเดือนก่อน +1

    10:45 - One quick thing, I'm not sure if you've mainly done a lot of programming in C++ or something but, in C it's redundant to cast the return value of malloc (or its derivatives). C is very loose about its types and all pointers are really just the same type (void*) when interacting with one another.

    • @hoff._world
      @hoff._world  3 หลายเดือนก่อน +5

      I just prefer to do it so I explicitly always know what I'm dealing with, more of a 'best practice' then for any functional reason.

  • @gronki1
    @gronki1 4 หลายเดือนก่อน +3

    Nice channel, subscribed! But small remark, please next time make your font at least twice the size 🙂 cheers from Poland!

    • @hoff._world
      @hoff._world  4 หลายเดือนก่อน

      Will do, thanks for your comment!

  • @deadsi
    @deadsi 4 หลายเดือนก่อน +7

    Dear Linux Daemon,
    [your message]
    Sincerely yours,
    [your name]
    Saved you 50 minutes

    • @hoff._world
      @hoff._world  4 หลายเดือนก่อน +2

      Funnily enough im gonna do a video talking about how daemons can talk to each other over the network..... they will be doing exactly this :PP

  • @Andrii-zc4dp
    @Andrii-zc4dp 4 หลายเดือนก่อน +1

    Amazing, I already know all this, and I use arch btw, but, still a nice thing to watch in background! Respect for not using VSCode, but I wish you used Vim

    • @ivymuncher
      @ivymuncher 4 หลายเดือนก่อน +2

      are we seriously still doing this editor war shit 😭

    • @hoff._world
      @hoff._world  4 หลายเดือนก่อน

      Yeah I use vim on the CLI but with this syscall API vim wanted to generate file move events which was really weird, that still works correctly for the intent of seeing if someone edited ur file ig but nano generated the events one would expect so I used that for the demo.

    • @hoi-polloi905
      @hoi-polloi905 4 หลายเดือนก่อน

      Lmao vim is a cute program but is lackluster when you start working with large code bases

  • @OhCynicalHD
    @OhCynicalHD 3 หลายเดือนก่อน +4

    Any good books or tutorials on this? I have a python and JavaScript background and will eventually be taking computer science classes. Wanted to learn C. I know the basics of assembly x86. I was having a hard time really understanding what’s going on with the API

    • @hoff._world
      @hoff._world  3 หลายเดือนก่อน +2

      ill do some kinda vid on it

  • @bigl9527
    @bigl9527 4 หลายเดือนก่อน +1

    Your cam is in the way of the terminal. I suggest to pipe your webcam output to MPV so that it show in your screen and you can move it around like a normal window.

    • @hoff._world
      @hoff._world  4 หลายเดือนก่อน

      Yep I noticed that after recording... Rookie error by me not being aware of where it is sometimes. Thanks for the suggestion I'll have a look.

    • @bigl9527
      @bigl9527 4 หลายเดือนก่อน

      @@hoff._world glad to help

  • @yurisousan
    @yurisousan 2 หลายเดือนก่อน

    Starting my journey in tutorial series, after started watch the last tutorial and not understand anything 😂.
    It is me, not you. You explain very well and is funny, my problem is keep my mind in english and keep my focus on code 🤣 Let’s go!

    • @hoff._world
      @hoff._world  2 หลายเดือนก่อน +1

      best of luck with it my guy I know they're quite the elephants to take on :D

  • @Blueeeeeee
    @Blueeeeeee 4 หลายเดือนก่อน

    Thumbs up just for the thumbnail x)

  • @godDIEmanLIVE
    @godDIEmanLIVE 3 หลายเดือนก่อน

    Really cool.

  • @benhetland576
    @benhetland576 4 หลายเดือนก่อน +1

    Around 34:00 you might want to assure you read at least _(sizeof *watchEvent)_ bytes too, or else you risk accessing invalid buffer content that wasn't actually filled by _read._ It can be done by changing "bufferPointer < buffer+..." to something like "bufferPointer+(sizeof *watchEvent) < buffer+..." in the _for_ condition. Remember the _read_ system call may return less that you ask for, and even 0 bytes!

    • @hoff._world
      @hoff._world  4 หลายเดือนก่อน +4

      True thanks for the note. I suppose the lesson to learn is that good programming requires trust issues :P

    • @king94596511
      @king94596511 4 หลายเดือนก่อน

      Hello, after testing with "bufferPointer+(sizeof *watchEvent) < buffer+..." in the for condition, the inotify event is not detected at all. I think adding the actual size of the struct inotify_event could lead to skipping the loop.

    • @benhetland576
      @benhetland576 4 หลายเดือนก่อน

      @@king94596511 Yes, but that probably means you have read a few bytes from the file descriptor ("event queue"), but not yet the full size of a watchEvent. Did you check the actual value of that _readLength?_ Then we're also left with another challenge; how to handle whatever data is left in the buffer after the _for_ loop. (The _bufferPointer_ may even point beyond the end of the data read!) You cannot just discard it, because then all the subsequent reads will be out of sync with the event records, and it can be hard to get back in sync again. Probably just move it to the beginning of the buffer and let the _read_ append from there. This requires some adjustments to both the max count to read and the returned _readLength_ though. Some mgmt related to the variable length of the records too, so a bit of things to get right there, unfortunately!

  • @Vojzzo122
    @Vojzzo122 4 หลายเดือนก่อน

    great video! i was thinking, wouldn't an enum be easier for the error codes?

    • @hoff._world
      @hoff._world  4 หลายเดือนก่อน

      Yeah you totally could. One of the things I love about programming is there are so many different ways to do the same thing :D

  • @pwhv
    @pwhv 4 หลายเดือนก่อน

    hello, nice video! hey whats your desktop environment?

    • @hoff._world
      @hoff._world  4 หลายเดือนก่อน

      KDE Plasma my guy

    • @Wakizu
      @Wakizu 4 หลายเดือนก่อน

      kde plasma

  • @skeleton_craftGaming
    @skeleton_craftGaming 4 หลายเดือนก่อน

    A lot of the cstdlib is implemented via syscall in unix like systems...

  • @alwin5995
    @alwin5995 4 หลายเดือนก่อน

    Insane man. I am a big fan of native development in Rust. Would be awesome if you have videos on it too.

    • @hoff._world
      @hoff._world  4 หลายเดือนก่อน

      unfortunately rust is not among my repertoire, more of a C and Golang enjoyer. I have heard very good things about it though, may learn in future!

  • @benhetland576
    @benhetland576 4 หลายเดือนก่อน +2

    31:00 Back in the days this was even how we could read directory entries on a *nix system, because as we know "everything is a file" and even a directory could be "open"-ed like one! A terrible non-portable way of doing it, and totally bound to the internal format of one specific file system. IIRC it probably was on a Venix machine I did this.

    • @hoff._world
      @hoff._world  4 หลายเดือนก่อน

      It is one of the most powerful and yet most dangerous things about a UNIX system I would say hahaha

  • @sanctuary_of_soul
    @sanctuary_of_soul 4 หลายเดือนก่อน

    Can somebody help with implementing this watchdog on MacOs? I tried to find libraries, there seems to be a fswatch, but i actually do not know how to properly perform linking.
    I would really appreciate if somebody had me pushed in some direction here.
    Thank you very much!
    Tutorial is great!

  • @Alrighty-Then
    @Alrighty-Then 2 หลายเดือนก่อน +3

    11:33
    holy jump scare

  • @90daysofspanish-lf9me
    @90daysofspanish-lf9me 4 หลายเดือนก่อน

    Legend

  • @H3fAlUmP
    @H3fAlUmP 4 หลายเดือนก่อน +1

    Nice vid, one thing tho. When writing in C be very careful with `str*` functions. `strlen` is not safe bcs with a string not null-terminated it accesses memory beyond the buffer. You could use strnlen, or better yet, strnlen_s. Nice vid regardless :) cheers

    • @hoff._world
      @hoff._world  4 หลายเดือนก่อน

      You are right my friend. Considering we are grabbing the string from argv I am trusting the shell to get it right, but on any other user input that is the way to go :D

    • @Zeutomehr
      @Zeutomehr 4 หลายเดือนก่อน

      glibc doesn't implement annex K functions as far as I'm aware

    • @kruruneiwyn2107
      @kruruneiwyn2107 4 หลายเดือนก่อน

      @@Zeutomehr correct for like 99% of them I remember there is small number of exceptions but don't recall which

  • @Nitant-qz3ie
    @Nitant-qz3ie หลายเดือนก่อน

    just needed a help , libnotify and glib gives no file found even after i included from source directory of my system of nixos

  • @JustKatoh
    @JustKatoh 4 หลายเดือนก่อน +3

    No one going to talk about how he is using Kate to write all this?
    People crying over why VsCode/Vim/Emacs are the best, meanwhile mans been chillin with Kate watching the world bun, Is he a psycho?

    • @hoff._world
      @hoff._world  4 หลายเดือนก่อน +1

      Yep clinically diagnosed with Kate enjoyer disorder

  • @cuba6959
    @cuba6959 4 หลายเดือนก่อน

    awesome thumbnail

  • @remek712
    @remek712 4 หลายเดือนก่อน +1

    How to handle pressure in Scrum Sprints as a developer

  • @deonmarais3375
    @deonmarais3375 4 หลายเดือนก่อน +2

    Thanks, useful video.
    To get it to build correctly I needed to change the order of the gcc command line in Makefile.
    ```
    CFLAGS= -Wall -pedantic -std=gnu99
    all: rolexhound
    rolexhound:
    gcc $(CFLAGS) rolexhound.c -o rolexhoundd `pkg-config --cflags --libs libnotify`
    ```

  • @ferasalfarsi897
    @ferasalfarsi897 4 หลายเดือนก่อน

    Can you please zoom in when you are typing the code, so we can read it.

  • @ge0x1
    @ge0x1 4 หลายเดือนก่อน +1

    Bro please do an advance C course, i love the way you're explaining things. Do you have any courses on udemy?

    • @hoff._world
      @hoff._world  4 หลายเดือนก่อน +7

      nah im not a grifter, shit will be up for free dont stress bruv

    • @thats-no-moon
      @thats-no-moon 3 หลายเดือนก่อน

      @@hoff._world right on. font still too small :-D

    • @hoff._world
      @hoff._world  3 หลายเดือนก่อน +2

      @thats-no-moon that's the catch, it's free but u pay with ur eyesight

    • @biigsmokee
      @biigsmokee 3 หลายเดือนก่อน

      ​@@hoff._worldwhat a legend
      i know this has some security implications, is there now a way around this to hide your program from inode calls? or is this bulletproof

  • @AlexMartin-vi4eq
    @AlexMartin-vi4eq 4 หลายเดือนก่อน

    How have you customized Kate to suggest library functions?

    • @hoff._world
      @hoff._world  4 หลายเดือนก่อน +1

      Kate supports configuring LSP Clients. You can do it in the settings menu.

  • @fabriciodultra3987
    @fabriciodultra3987 4 หลายเดือนก่อน

    tks man!!!

    • @hoff._world
      @hoff._world  4 หลายเดือนก่อน

      you got it chef

  • @ChrispyChris3
    @ChrispyChris3 4 หลายเดือนก่อน +1

    I'm a bit curious about the daemon you said you wrote for your girl. What did it even do? Does she run a Linux machine then?

    • @hoff._world
      @hoff._world  4 หลายเดือนก่อน +2

      My girl at the time, ex-girl now :P It was a simple Python web-scraping daemon that sent her a notification when a very niche store (no email notifs) had some piece of clothing she wanted back in stock.
      She ran Manjaro for around 4 yrs but recently swapped it back to Win when it had some issues.

  • @dauda-dev5554
    @dauda-dev5554 4 หลายเดือนก่อน +1

    how to set up the daemon to os startup would be nice to see to all this. thanks for video.

    • @CJ1337HF
      @CJ1337HF 4 หลายเดือนก่อน

      Fairly easy via systemd. Just a small config file

    • @hoff._world
      @hoff._world  4 หลายเดือนก่อน

      @CJ1337HF this is true, however if the daemon is started before your desktop env this can cause issues initialising with libnotify. May have to do some playing around, or it might just work, idk hahaha

    • @CJ1337HF
      @CJ1337HF 4 หลายเดือนก่อน +1

      @@hoff._world you can solve thus easily by setting the target correctly

  •  4 หลายเดือนก่อน +4

    This guy writes code in Kate. Subscribed.

    • @hoff._world
      @hoff._world  4 หลายเดือนก่อน +2

      When anyone talks shit about it I just say "Let me guess, you need more?"

  • @thats-no-moon
    @thats-no-moon 3 หลายเดือนก่อน

    Yeah, vid is pretty good, NGL

    • @hoff._world
      @hoff._world  3 หลายเดือนก่อน

      that boat in ur pfp looks pretty good ngl

  • @damiemcrea9953
    @damiemcrea9953 4 หลายเดือนก่อน

    hell yeah man this rules

    • @hoff._world
      @hoff._world  4 หลายเดือนก่อน +1

      You rule bro thanks for the support!

  • @bartek...
    @bartek... 4 หลายเดือนก่อน

    Letter's to small to watch it from the bed, lucky for me today I'll sleep on the desk 🍻
    Cool code and walk true!!! Is really solid. What's the prep/improvise ratio?
    I love to learn C... I should start with it when I've know nothing, now it's harder. What's worry me, why all of it have a perfect sense for me? I don't understand that!!! I just seen artifacts of it in so many places of my os.

    • @hoff._world
      @hoff._world  4 หลายเดือนก่อน +1

      Hey thanks for the comment! As mentioned I did write up the program beforehand, took maybe 20-30 minutes? It is quite a basic program; whatever I improvised in the video would come out roughly the same as what I wrote beforehand.
      I don't film with scripts, at best I have a text file with some dot points which just feels more natural to me. Tbh I think I'm still a bit robotic in places so trying to work on it.
      C as a language is nice to learn because you can really start to think like a computer. Higher level languages abstract a lot of things away from you, so when you program in C it's like you're having a conversation with the CPU :)

    • @bartek...
      @bartek... 4 หลายเดือนก่อน

      @@hoff._world you do have a good presentation skills, this is something I'm trying to stress myself a bit more. Half scripted? You are good natural. Keep it this way.
      C... I know... I'm just lazy fuck, sticked with those languages that are doing for us every stupid mistake... and BTW most of new CLI apps do not provide man 🫨 they are 12 fucks apps and forgetting about first one. fuck!!!! RTFM

    • @mikereynolds1368
      @mikereynolds1368 4 หลายเดือนก่อน +2

      ​@@hoff._world tbh it did not have a robotic feel to me. It all felt pretty natural.

    • @hoff._world
      @hoff._world  4 หลายเดือนก่อน

      @mikereynolds1368 cheers Mike that's good to hear

  • @TheWizard45134
    @TheWizard45134 4 หลายเดือนก่อน

    No way! I actually understood the thing. This is epic! Dont be yoo silly btw

    • @hoff._world
      @hoff._world  4 หลายเดือนก่อน +1

      Thanks. I'll try not to be too silly but I'm just such a funny little character aren't I

  • @varshneydevansh
    @varshneydevansh 4 หลายเดือนก่อน

    you got a sub

    • @varshneydevansh
      @varshneydevansh 4 หลายเดือนก่อน +1

      Today I unblocked my TH-cam recommendation to see if there is something new and good to watch then there was this video at the first recommended to me.

    • @hoff._world
      @hoff._world  4 หลายเดือนก่อน

      Thanks I appreciate it!

  • @ishangrover1453
    @ishangrover1453 4 หลายเดือนก่อน +1

    Why did you not make a service file and load the binary of program in the service file and then start with systemctl

    • @hoff._world
      @hoff._world  4 หลายเดือนก่อน

      because the video was 50 minutes long 😬

    • @pines6110
      @pines6110 4 หลายเดือนก่อน

      Wouldn't mind it being 1:20 if it tells me everything @@hoff._world

  • @unixandroid
    @unixandroid 4 หลายเดือนก่อน

    Hey brother
    Could you recommend books or websites to learn programming?
    I don't know anything about it
    thanks man

    • @hoff._world
      @hoff._world  4 หลายเดือนก่อน

      will do a vid on it, topic is too broad to answer in a yt comment

    • @unixandroid
      @unixandroid 3 หลายเดือนก่อน

      @@hoff._world ok thank you

  • @Proferk
    @Proferk 4 หลายเดือนก่อน

    What theme do you use for your system?

    • @hoff._world
      @hoff._world  4 หลายเดือนก่อน

      It's a plasma theme I made myself, haven't published it but I may one day if I do a vid showing it off

  • @okuno54
    @okuno54 4 หลายเดือนก่อน

    Bro really be coming up to Tony Hoare - rocking variable declarations at the top of his functions like it's the ANSI C days (as if the flexible array members aren't from C99) - telling him that his billion dollar mistake is fine actually and that the legend himself has a skill issue XD
    fr tho, nullability is useful, that's why you got `Option`, so you get it only where you need it, oh and it's useful for more than just pointers

    • @hoff._world
      @hoff._world  4 หลายเดือนก่อน +1

      yeah my friend I'm young and arrogant ofc I know better than Tony :P

  • @danielniels22
    @danielniels22 3 หลายเดือนก่อน

    am i okay to follow with MacOS? will watch this in the future after finishing my current mobile dev project, since this is totally different field

    • @hoff._world
      @hoff._world  3 หลายเดือนก่อน +1

      nah probs not, macOS doesn't have the inotify interface so you'd have to replace it with something else

    • @danielniels22
      @danielniels22 3 หลายเดือนก่อน

      @@hoff._world what OS are you guys using? sorry i'm new into this computer science world, i'm kind of randomly learn stuff. would like to know what is the name of this sub-discipline

    • @hoff._world
      @hoff._world  3 หลายเดือนก่อน +2

      @nielscassius3875 the title of the video is "How to write a LINUX Daemon" :P

    • @danielniels22
      @danielniels22 3 หลายเดือนก่อน

      @@hoff._world thank you. i mean what is the name of this whole discipline.. the things that I know for example is like data science, machine learning, web programming... what about this? so i know where i could find a roadmap...

    • @hoff._world
      @hoff._world  3 หลายเดือนก่อน +1

      @neilcassius3875 ah, this is commonly referred to as "systems programming". Also called "UNIX programming" or "linux programming" or sometimes "network programming" (that last one doesn't explicitly apply to this video but is in a similar field). Hope that helps!

  • @redhawk3385
    @redhawk3385 2 หลายเดือนก่อน +3

    based kate editor

    • @hoff._world
      @hoff._world  2 หลายเดือนก่อน +3

      kate chads rise up from the ashes of the vim vs emacs war

    • @TooShyForTea
      @TooShyForTea หลายเดือนก่อน

      Kate is a great notepad alternative. I use nvim for coding but kate is nice for one offs and pair programming.

    • @ihavenoenem1es
      @ihavenoenem1es หลายเดือนก่อน

      @@hoff._world lol, what is special about it? Great channel btw, it's a gem, in a mud of soydevs here in youtube.

    • @hoff._world
      @hoff._world  หลายเดือนก่อน +1

      @@ihavenoenem1es it's light and responsive while having the features I want (split view, inbuilt term, LSP client, etc) vs. vscode which feels slow. Also integrates nicely with my DE which is plasma since kate is a KDE editor

  • @user-xb2kq8qx9j
    @user-xb2kq8qx9j 3 หลายเดือนก่อน

    Can this be cross platform with compiler as an enabler ? Asking from title .

    • @hoff._world
      @hoff._world  3 หลายเดือนก่อน +1

      nope, we use linux-only system calls in this one

  • @calebuic4310
    @calebuic4310 4 หลายเดือนก่อน

    Is that textbook on the thumbnail good?

    • @hoff._world
      @hoff._world  4 หลายเดือนก่อน

      ye it's pretty OG

  • @filintodelgado
    @filintodelgado 4 หลายเดือนก่อน +1

    You could have used `char *basename(char *path)` to get the basename from the path

    • @hoff._world
      @hoff._world  4 หลายเดือนก่อน +1

      That is true, and equivalents exist in almost all langs. However string tokenisation is a very common thing in programming in general so I thought it would be good to go over it using this as an example :)

    • @filintodelgado
      @filintodelgado 4 หลายเดือนก่อน

      @@hoff._world you did the right choice as I have never heard of it and now I know. Might be useful someday

  • @yacinefodil5014
    @yacinefodil5014 4 หลายเดือนก่อน +3

    Programming in C scratches an itch no other programming language does

    • @hoff._world
      @hoff._world  4 หลายเดือนก่อน +1

      to me it is like you are having a one-to-one chat with the CPU

    • @bimmy4664
      @bimmy4664 4 หลายเดือนก่อน +1

      @@hoff._world assembly language allows you to pretty much directly manipulate the CPU and all its registers. C obfuscates a lot of that to make it more human-readable.

    • @hoff._world
      @hoff._world  4 หลายเดือนก่อน +1

      @@bimmy4664 yes, if you think about it the entire field of computer science is about smart abstraction