Readit News logoReadit News
emidoots · 3 years ago
Wow, didn't expect to see @xfennec pop up on hacker news while drinking my coffee this morning! I don't know if he'll see this, to be honest didn't know he was still doing things - but this person basically got me into programming and game development-I really can't believe it.

xfennec (and some friends?) I think built a game engine called Raydium, and one of their games called Mania Drive-a Track Mania clone-got distributed with OpenSuse installation CDs back in the day. When I was just like 12 years old, my dad installed that on the family computer and it was all we had, Mania Drive was one of the coolest games on there. Me and my siblings played that for literally days and months on end, making crazy levels we couldn't beat without knowing every turn. It was a huge part of our childhood.

Their game engine was in C with PHP scripting, I remember posting some levels to their forums and asking, in retrospect super dumb, questions and they were so polite and friendly. I remember us joking at the time that the French seemed like these god-like game developers, it had such a profound impact on us, I even wrote about it last year and linked a video of Mania Drive first[0]. I went on to learn Python and then lower-level languages as a result. I'm not sure I'd be coding today without them, to be honest.

Sorry it's off-topic, just really blown away to see a username like that pop up in my feed. Really goes to show that kindness + some cool open source software can have profound effect on people.

[0] https://devlog.hexops.com/2021/increasing-my-contribution-to...

xfennec · 3 years ago
Xfennec here, thank you so much for this message. ManiaDrive was a small game made with a bunch of friends, I'm so glad it had an impact on you. I'm now a dad, and it makes me very emotional to read this. Thanks again.
evilos · 3 years ago
Things like this is what makes the internet feel so human sometimes!
dilap · 3 years ago
Such a great story. This part made me lol:

> // Don't remove this print statement. Game will crash!

:-)

yobert · 3 years ago
I'd never heard of that game. Trying it now and it's great fun. Really enjoying the soundtrack.
ktm5j · 3 years ago
I love stuff like this, thanks for sharing!!
jmclnx · 3 years ago
This is one thing I really miss on Linux when compared with the BSDs, especially with dd(1). On BSD you can press ^t to see the status of a command. All you need to do is issue this command to activate it:

% stty status '^t'

btw, for Linux dd(1) I know about "status=progress", but for me it is a bit hard to remember and specific to dd(1). But, nice little utility :)

jagged-chisel · 3 years ago

    dd if=<input> | pv | dd of=<output>
to get a count of bytes passing through, or

    pv <input> | dd of=<output>
to get actual completion progress. For tarchives,

    pv <tarchive> | tar x
Compression progress

    pv <file> | bzip2 > <file>.bz2

cellularmitosis · 3 years ago
This is also handy when using socat to pipe across a network. You can use pv on both ends, one looking at compressed and the other looking at uncompressed data, in order to observe the real-time compression ratio.

tar c foo | pv | gzip | socat - tcp-listen:9999

socat tcp:bar:9999 - | pv > foo.tar.gz

If pv shows that you aren’t saturating your network and are cpu limited, replace gzip with lzop. If vice versa, replace gzip with something more aggressive.

Self-Perfection · 3 years ago
pv also has little known ability to watch already running process in similar fashion to progress tool

Try

cp $BIGFILE ${BIGFILE}_1 & pv --watchfd $(pidof cp)

anonymousiam · 3 years ago
'pv' is great, but you need to have the foresight to use it in your command before you run it. 'progress' seems great for those cases where you didn't realize your job was going to take so long, and you don't want to start it all over again.
mat_epice · 3 years ago
You can get status on-the-fly from dd on Linux as well by sending the USR1 signal.

  [user@machine ~]$ dd if=/dev/zero of=/dev/null &
  [1] 3254428
  [user@machine ~]$ kill -USR1 %1
  19061394+0 records in
  19061393+0 records out
  9759433216 bytes (9.8 GB, 9.1 GiB) copied, 6.06968 s, 1.5 GB/s
  [user@machine ~]$ kill -USR1 %1
  25868762+0 records in
  25868762+0 records out
  13244806144 bytes (13 GB, 12 GiB) copied, 8.97352 s, 1.5 GB/s
  [user@machine ~]$ kill %1
  [1]+  Terminated             dd if=/dev/zero of=/dev/null

kazinator · 3 years ago
This only works because you're allowing backgrounded processes to write to the terminal (stty -tostop).

Try stty tostop

  kaz@sun-go:~/txr$ stty -tostop
  kaz@sun-go:~/txr$ dd if=/dev/zero of=/dev/null &
  [1] 14604
  kaz@sun-go:~/txr$ kill -USR1 %1
  kaz@sun-go:~/txr$ 1142200+0 records in
  1142200+0 records out
  584806400 bytes (585 MB, 558 MiB) copied, 2.62053 s, 223 MB/s

  kaz@sun-go:~/txr$ kill -USR1 %1
  2054884+0 records in
  2054883+0 records out
  1052100096 bytes (1.1 GB, 1003 MiB) copied, 4.70066 s, 224 MB/s
  kaz@sun-go:~/txr$
  kaz@sun-go:~/txr$ stty tostop
  kaz@sun-go:~/txr$ kill -USR1 %1
  kaz@sun-go:~/txr$ kill -USR1 %1

  [1]+  Stopped                 dd if=/dev/zero of=/dev/null
  kaz@sun-go:~/txr$ kill -USR1 %1

  [1]+  Stopped                 dd if=/dev/zero of=/dev/null
  kaz@sun-go:~/txr$

amatecha · 3 years ago
Ah, exactly the comment I was hoping to see on here as I forgot how you could query this. Thanks!
j33zusjuice · 3 years ago
How often do you use dd that this really matters? Just curious. I’ve run dd maybe 20 times in the 5-6 years I’ve worked with Linux professionally.
mtlmtlmtlmtl · 3 years ago
Probably not used as much by programmers, but it's a great swiss army knife type tool for copying stuff around with more finegrained control. Sysadmins use it a ton. Probably more often through scripts than directly.

The nice thing with ^T versus status=progress is that ^T will work even when dd was invoked from some script that you don't necessarily want to edit, etc.

loeg · 3 years ago
^t (SIGINFO) works with a lot more than just dd. It also triggers kernel behavior (printing the current waitchannel, e.g., named lock, if one is relevant) which can be useful for diagnosing why a command (any command) is hanging. (Is it busy in userspace, or in the kernel? And if in the kernel, where?)
guenthert · 3 years ago
I used it a lot (didn't miss the progress bar though). With it's options to control caching, it can be used as bare-bones single-threaded performance test for sequential access. Won't replace more elaborate test suites, but has its use as sanity-check.
awelxtr · 3 years ago
I use it constantly. My company's products are flashed using an sd card and to create it I dd into and from the sd card several times a week
jtode · 3 years ago
If you get into anything Raspberry Pi-based, you'll do it a lot. They are shockingly stable once booted, but an M.2 port is my dearest with for the Pi5.
warp · 3 years ago
I occasionally have a new stupid idea for which I want to use a fresh install on a Raspberry Pi, so I flash a new SD card with dd maybe 4-5 times per year.

Inevitably it turns out my idea was not as useful as it seemed when it first popped in my head, so after a few weeks/months that Pi is turned off and returned to the pi drawer.... ready for the next brilliant idea.

(ps. I typically use the `pv` command to see progress with stuff other than dd)

squarefoot · 3 years ago
dd is the command to use when transferring bootable images onto USB dongles for installations; when working with embedded boards, especially for testing, one can use it like 20 times or more in a single day. Having a progress feedback isn't vital per se, but becomes useful when using by mistake a slow USB dongle, or plugging it in the wrong, slower, port.
anthomtb · 3 years ago
I very rarely use dd. And thank $DEITY for that, because my typical use case is creating a USB boot drive and then backing up or recovering what I can from a failing disk.
ordu · 3 years ago
The infrequency just does the issue worse, because every time I want to see a progress, I'd remember that I needed to add a special option to dd.
jagged-chisel · 3 years ago
Regardless of frequency of use, I always want progress and to verify we haven't stalled. With no output, I'm at the mercy of $RANDOM_BS.
bennyp101 · 3 years ago
At least 10 times this year so far to copy an image to sd cards. Its reliable and easy
kazinator · 3 years ago
I'm astonished that the BSD projects are merging un-Unix-like fluff like this.

Meanwhile, the Linux kernel has removed Shift-PgUp scrollback from the console.

jmclnx · 3 years ago
What does this mean ? IIRC ^t has been in the BSD for over 20 years, maybe even in early days. ^t just maps to a signal.
mardifoufs · 3 years ago
Why did they do that? I'm sure there's a good reason but it sounds interesting!
cryptonector · 3 years ago
WAT, how is this "un-Unix-like"?
Ballas · 3 years ago
Perhaps an alias in your .bashrc for dd would solve it? I usually just use ddrescue most of the time (primarily because I prefer it's usage syntax, but it also reports status).

Similarly you could alias rsync instead of copy and move:

   alias pcp='rsync -au --info=progress2'
   alias pmv='rsync -aP --info=progress2 --remove-source-files'

animal-hash · 3 years ago
There's also dd status

       status=LEVEL
              The LEVEL of information to print to stderr; 'none'
              suppresses everything but error messages, 'noxfer'
              suppresses the final transfer statistics, 'progress' shows
              periodic transfer statistics


and pv

    pv - monitor the progress of data through a pipe

So with pv, you can do something like

    dd if=/dev/zero count=2 bs=512 | pv | dd of=/dev/null
to visualize your dd progress.

Deleted Comment

thedougd · 3 years ago
Ctrl-t works for me on DD on Linux.

Deleted Comment

yrro · 3 years ago
Not here. I guess you've somehow got ^T to send SIGUSR1 to the foreground process?
loeg · 3 years ago
Can't speak to the others, but on FreeBSD you don't need to activate ^t (SIGINFO); it just works that way out of the box.
_joel · 3 years ago
kill -USR1 {dd pid} ;)
masklinn · 3 years ago
The problem with usr1 is it defaults to killing processes, so you may only use it with processes you know handle it that way.

Info defaults to dumping generic stuff, it’s completely safe (unless a dev decided to handle it by dying but I would not want to use their software).

emmelaich · 3 years ago
FWIW, dd will give a status if signalled. SIGUSR1 on Linux, SIGINFO on macos.
Nursie · 3 years ago
Linux did also spits out status if you kill -USR1 it, which is useful when you forgot to progress=status it.
tssva · 3 years ago
Don't try to remember adding status=progress. Add a shell alias for dd.
loeg · 3 years ago
And then remember to copy that to every machine you use, I guess. Including one-offs.
sillystuff · 3 years ago
You can send a USR1 signal to dd and it will print its progress.

Deleted Comment

lathiat · 3 years ago
I use the pv “Pipe Viewer” tool to do the same. You can either put it in the middle of a pipe, or pass it a PID using -p http://www.ivarch.com/programs/pv.shtml

It works by reading /proc/PID/fdinfo/*

mavhc · 3 years ago
I used PV's rate limit when trying to do to a multi terabyte zfs send, slow it down and speed it back up as required
geraldhh · 3 years ago
why would one want to slow it down?
foreigner · 3 years ago
I use pv all the time and didn't know you could use it to watch an existing process. Thanks for the tip!
zamubafoo · 3 years ago
That's interesting! I often found myself forgetting to turn on progress flags on many data transfer jobs and the occasional data transform batch job that I looked into something like this.

I found that `iotop` is great for this kind of thing. Sure, you have to either start it before your process starts or your accumulated total is off, but usually I'm not tracking progress for files less than 1GB so being off by kilobytes is fine.

My go-to's are `sudo iotop -aoP` for general monitoring, adding the `-p` flag if it's just a specific process, or `-u` if I'm monitoring something that is possibly transient.

stack_underflow · 3 years ago
One of my quick-and-dirty gotos for getting a rough idea of buffered-writes size + disk-write activity on random linux systems is: `watch -n1 grep -ie dirty -e writeback /proc/meminfo`.

You can invoke `sync` to watch the buffered-writes queue burn down when you have lots of pending writes.

see: `LESS=+/meminfo man proc` or https://github.com/torvalds/linux/blob/master/Documentation/... for more info

bornfreddy · 3 years ago
I also often forgot to add progress flags, but lately I don't even bother... I just start, then `progress -w` or `watch progress -w`. Works nicely.
eps · 3 years ago
> It simply scans /proc for interesting commands, and then looks at directories fd and fdinfo to find opened files and seek positions, and reports status for the largest file.

Wasn't expecting something as simple that at all. Bloody ingenious.

marcodiego · 3 years ago
IMHO, it would be much better if linux implement SIGINFO. It has been present in BSD's since forever and there is a good linux implementation: https://lkml.org/lkml/2019/6/5/174
pstoll · 3 years ago
Random aside - I know formatting discussions border on the religious (and why something like gofmt is the only correct answer & yet I am also good with spaces for Python) but..

Did anyone else look at the code and ask themselves- what is the actual formatting standard being used?

Looked like a mix of “open brace on same line, 4 chars indent for code” then “open brace on new line, code at same zero indent”

Not a big deal obviously. Just something that tripped up my eyes scanning the code.

akritid · 3 years ago
From a quick look to one file, seems fairly consistent. Perhaps most unorthodox but at the same time easiest to justify: function bodies skip one level of indentation. The curly brace of function body at column zero is actually a separate, very traditional style. It's just that both styles apply to function bodies, there is no other causal relationship. Finally, indentation is 4 spaces, and tabs are expanded. Of course a very few places may be miss-styled, as happens with hand crafted code. While definitely sinful for not indenting with tabs as God intended, the style is not messy
antihero · 3 years ago
Yeah it just looks messy and harder to read when it’s inconsistent
reaperducer · 3 years ago
Did anyone else look at the code and ask themselves- what is the actual formatting standard being used?

Looks like a combination of Whitesmiths and ChatGPT.

dang · 3 years ago
Related:

Show HN: Linux tool to show progress for cp, rm, dd, etc. - https://news.ycombinator.com/item?id=8023713 - July 2014 (53 comments)

(as it doesn't seem to have been posted by the creator, Show HN was a mislabel there)