it doesn't, ctrl-z only suspends process and switches to backgroud - the thing is still alive
try ctrl-z and then type bg command - you will see a list, you can resume with fg [number]
Ctrl-z by itself doesn't actually switch the process to run in the background, it stops the process. Running 'bg' is what starts the process back up running in the background, 'fg', like you said, resumes the process in the foreground and 'jobs' is the command you can run to see a list of processes that are running.
Since the question was "Ctrl-z works universally", I feel obliged to point out that ctrl-z sends SIGTSTP, which can be blocked--not to be confused with SIGSTOP, which cannot be blocked. I don't know of any program that does intercept SIGTSTP (except a test program I wrote that tries to print the name of any signal it receives), and I suspect that "polite" interception would be to release a few resources and then accept being paused--but, in theory, a program could ignore it.
This is probably a stupid question, didn't know about bg and fg before. But after playing around with it, it feels pretty amazing, why even use screen/tmux when you have these?
Screen has aaugh easier interface for multitasking, including things like stderr not bleeding out from whatever background tasks you're running. Not to mention that switching back and forth between screens is what it's designed for and thus a lot easier than switching between job numbers. Also the ability to detach your screen and its running processes from being coupled to a specific login session, which is probably the main reason I started using screen instead of multiple terminals in the first place.
Back when I first started my CompSci degree, a friend of mine always "quit" emacs with ctrl-z. Or, at least he did until he managed to fill his entire home directory quota with emacs backup files that were never cleaned up...
Nope, because emacsclient ends up opening them all in the same process (that's the beauty/entire point): Fork off an emacs in the background:
emacs --daemon
Then run emacsclient to connect to it (open a new buffer in the daemon and switch to it):
emacsclient -nw some_file
When you "quit" (with C-x C-c), it really just quits that client, but the main emacs is left running.
This has a number of benefits: 1) no locks like you mention, 2) access to all open buffers (even unsaved) from every emacsclient that's currently running (since they're really all just opening buffers in a single instance), 3) blazing startup speed (emacs is already running, you're just connecting to it and splatting a new buffer to the terminal).
I still remember how happy I was when I found out about that. On all servers I use (at home and at work), starting an emacs daemon is usually among the first things I do after rebooting.
My "favorite" thing is when you hit Ctrl-C, and Vim says "Type :quit<Enter> to exit Vim". Vim isn't dumb. It knows what Ctrl-C means, it knows what you wanted to happen. But it's gonna make you do it its way anyway, because fuck you.
Actually, that's a feature... Ctrl-C exits insert mode. If it quit vim when in Normal mode, you'd accidentally quit Vim all the time. Less annoying to just show a helpful message in case you actually meant quit, than dump everyone who knows what Ctrl-C does back to a shell.
I think more important than exiting insert mode is (as I described in a peer comment, hopefully clearly) killing foreground processes you've spawned out of vim. 1) With exiting insert mode there's the option of using escape instead (or capslock or jk or whatever people bind it to), and 2), I think most importantly, with killing processes there's an actual race condition: if the command finishes after I decide to kill it and before vim registers my Ctrl-c, exiting is totally the wrong thing to do.
I would think that it's because ViM wants you to learn something about how the it works.
If it just exited with Ctrl-C, you'd never get to know about the : magic.
Not to mention Ctrl-C is ambiguous. What to do: Exit and save? Exit without saving? What if it's a new file? And probably others I'm not thinking about right now.
Python 2.7.9 (default, Mar 1 2015, 12:57:24)
[GCC 4.9.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> quit
Use quit() or Ctrl-D (i.e. EOF) to exit
>>>
It's been awhile since a fresh install but is it ViM. is Vi still around? I just seem to recall some things not working right. Such as not being able to ZZ or ZQ out of a file.
Vi is everywhere. Its part of the POSIX standard and comes out of the box (in one flavor or another) with every Linux Distro, OSX, HP-UX, AIX, Solaris, Darwin, FreeBSD, OpenBSD, and DragonFlyBSD.
ViM is just Vi iMproved. They share most their keybinds but VIM has the whole plugin architecture thing.
This is a big sticking point for a lot of VIM users [1]. If you ever end up on a Unix box that doesn't have VIM, you can always fall back on Vi.
Eh, yeah, but it usually links to the "basic" version (which, I assume, is compatibility mode for old school vi).
root@dicks:~# which vi
/usr/bin/vi
root@dicks:~# file /usr/bin/vi
/usr/bin/vi: symbolic link to `/etc/alternatives/vi'
root@dicks:~# file /etc/alternatives/vi
/etc/alternatives/vi: symbolic link to `/usr/bin/vim.basic'
root@dicks:~# file /usr/bin/vim.basic
/usr/bin/vim.basic: ELF 64-bit LSB executable, x86-64, (snip)
root@dicks:~# vi --version
VIM - Vi IMproved 7.4 (2013 Aug 10, compiled Jan 2 2014 19:39:32)
I'd forgotten Keep Talking and Nobody Explodes existed, thanks for reminding me of it just in time for a LAN party this weekend. My printer is going to be working overtime tonight.
Well, technically, replacing everything between the Ganges and Gibralter, and between the Congo and the Alps, with butterscotch pudding would be a solution.
I'm pretty sure this solution figures as a subplot in one of the story arcs of Triangle & Robert (ancient webcomic about geometry, pudding and a space/time pair o' ducks).
I'll pay my (IB) fees and get actually my orders filled instead. Plus, if you're only playing with stocks, you're missing a lot of the possibilities with a margin account.
What happens when they completely break it? Do you have code to detect that or will someone be on hand to reimage the thing? Will that be a special majority vote scenario?
BTW this is the best thing since sliced bread. Good work. I can't wait.
This is a good point. When I first got dropped to a shell in a broom/IT closet, I thought gees I hope I don't accidentally fuck anything up. 4 days later I had to acknowledge I could barely intentionally fuck anything up.
How will you handle special key combinations such as Ctrl+C to interrupt what's running?
It looks like it will be the second-generation democracy mode. That looks a bit too easy: in theory we would simply have to follow the install guide line-by-line and it would work.
Will there be some sort of external chat/discussion forum? I seem to remember TPP having a subreddit and an IRC channel for discussing and voting on strategies. Especially useful since the official chat was flooded with commands.
Was there any thought to having line discipline as the voting system? As in voting on entries into the terminal up until the first new line character? It would increase the likelihood of having sensible inputs since interacting with a terminal is very different than a video game and there are only a small number of combinations of inputs that are meaningful to it. Also, any thought to disabling signals coming from the terminal? I could imagine a lot of SIG* spam.
What happens if someone put a reverse shell on the machine and SSH into it or anything to circumvent the normal gameplay flow?
How would you go to block all externals SSH connections? Hardware?
Answering the question in the introduction: No, I do not remember how chaotic Twitch Plays Pokemon was. I do not even know what you are talking about. And since you do not even give me a link, I am not sure I should care.
I finally figured out what this is, but the site was not very helpful.
Yes, but isn't it expected to find that information in the "About" section of the main site instead of needing to search for it? I am just asking for an introductory paragraph like the first paragraph in that Wikipedia article.
I apologize for my tone, but I still think it was a fair complaint.
I guess if I were writing it, I might have made [how chaotic Twitch Plays Pokemon was](a link), but it's not exactly something to go complaining about..
At difference of complaining about people complaining, which I see is worth your time...
Take it easy people. The web site was not clear for me, the author was asking for input so I raised my point. I already apologized for using the wrong words.
Protip: apologies added as an introductory clause to you talking about your rightness do not come across as very good apologies. It looks like a way to deflect negative response, not honest sorrow for trouble caused.
Huh, I'm surprised it was notable enough to have a Wikipedia page. I would have Googled, but figured the answer was in some walled garden or cryptic forum posts.
The code currently given in the stream is `while [ "$(date)" != "Sat Oct 31 16:00:00 EDT 2015" ]; do \ sleep 1; done` ... so I hope the process wakes up on the correct millisecond.
Why would it have to be the exact millisecond? "$(date)" will have that value for 1 second, assuming the format is correct. There is some very small timespan in which it could fail, but the chances are very much in favor of successfully exiting the loop.
And `date` returns a timestamp with seconds precision.
`time sh -c 'if [ "$(date)" != "Sat Oct 31 16:00:00 EDT 2015" ]; then sleep 1; fi'` took around 1.010 seconds on my machine, but that includes starting a new shell, so there's probably a much smaller than 1% chance that that particular second will be missed.
EDIT: here's a little program to test this:
#!/usr/bin/env bash
while true; do
target=$(expr $(date +%s) + 2)
while true; do
now=$(date +%s)
if [ "$now" != "$target" ]; then
if [ "$now" -gt "$target" ]; then
echo "FAIL :("
break
else
sleep 1
fi
else
echo "OK! :)"
break
fi
sleep 0.1
done
done
Adjust the "sleep 0.1" to increase or decrease the perecentage of failures. Remove to see that it (almost) never fails.
Even if you set the interval to the minimum possible, there is no upper bound on how long it may take to complete, or indeed, any guarantee that it will complete. In this case it doesn't matter, but I point this out because I've seen people trying to use this sort of logic in places where it does matter in the last three months.
You may already have figured this out, but just incase anyone is wondering what the potential problem here is...
If it doesn't wake up and run the date command in a certain timeframe then this while loops will run forever.
The chances of that happening, while greater than zero, are really small though. It'd be something like the loop checks the time at "15:59:59", doesn't match so it goes to sleep just a few milliseconds before "16:00:00" then wakes up and runs the date command again and hopefully the deities of the CPU clock & scheduling will do this before too many milliseconds go by and the time becomes "16:00:01", at which point the while-loop would be infinite since the exact moment in time it's waiting for is now in the past and cannot occur again. I suspect though, CPU clock ticks are measured in nanoseconds or something smaller than a millisecond so this while-loop shouldn't miss its exit criteria on any modern machine.
Also, there's a chance this is just a fancy splash screen or even just a screenshot and a Twitch employee will manually get things started when it's time.
"I suspect though, CPU clock ticks are measured in nanoseconds or something smaller than a millisecond so this while-loop shouldn't miss its exit criteria on any modern machine."
It's not a busy-wait. What matters is not CPU clock ticks, but how quickly an eligible-to-run program gets scheduled. That's still not going to be terribly long, of course.
The chat on the twitch page is live already and well worth looking at. They're currently arguing over which desktop environment to use. Some people just want to install FreeBSD instead.
Random binary dumps aren't what they used to be. You should manually decode some 8-bit ascii by hand:
$ python
Python 2.7.6
Type "help", "copyright", "credits" or "license" for more information.
>>> import random
>>> print(''.join([chr(random.randint(32,255))
for x in range(50)]).decode("latin-1"))
¿IBÄõq½¦Áºn}@õÖhzUÌÓQ£m5ë¢ümÇ®=ÇÆªLÛHt
Medium-quality random binary garbage. randint is an alias for randrange,[1] which produces "slightly uneven distributions" according to the docs before version 3.2.[2]
Any idea how to play this on Fedora without flash? I've tried gnome-twitch that crashes a LOT and now trying to use livestreamer-twitch-gui which is not able to find the stream.
The stream is offline (it starts tomorrow) so livestreamer won't find it now.
I'm not on Linux ATM but Twitch moved to HTML5 video a while ago [1]. You should be able to watch it in Chrome. Firefox seems to show a black window for all streams because of a JS error apparently.
I uninstalled Flash a while ago (and turned it off in Chrome) and have been watching Twitch with no issues.
Are you sure Twitch is on HTML5? IIRC, the blog post you linked to only mentions the controls being in HTML5, not the player itself. The other component that switched from Flash to HTML5 was the chat player I believe.
Attempting to watch Twitch with Flash disabled on Chrome and Firefox on Windows displays the "You need Adobe Flash Player to watch this video. " message.
I don't know Twitch's rules that well, but they have a Programming genre and I rarely see games there. But, I have seen Twitch developers stream non-game related stuff.
They have a "creative" section that a lot of non gaming stuff falls into. A few months ago there was a twitch plays a neural network thing, where people in the chat told the neural network what to hallucinate: https://www.youtube.com/watch?v=IREsx-xWQ0g
Is there a minimum 'vote' threshold, or if I'm the only person connected at a certain point in time, do I get free - albeit slow and insanely frustrating - control of the 'machine'?
I just flagged this because it (and the other post of the same thing) blows out the page width and makes everything else wrap to the full length of the string, which is considerably more than the average screen width. Hoping an admin can edit it.
Definitely interesting to see these twitch events. For those curious Twitch has a IRC backend for the chatrooms, so if you can code an IRC bot, you can easily allow twitch users to automate many interesting things.
The problem is that it is possible to put the machine into a state where it does not accept key inputs, so the only way to get it out is to do a "hard reset". We are still not sure how to handle that (Possible a confirmation box where they have to type "yes" to do it?). That whole subsystem is still undergoing revisions, so we are going to do some testing later and see if we can make that less easily exploited.
If they manage to install Arch Linux with an equal amount of people which were playing Twitch plays Pokémon, I will post a video of me eating my sandals.
That would only work in the event that a majority of users coordinate their efforts to deploy such a thing. Seems like it'd be easier for them to setup a VPS.
I have no idea. I don't think the crowd will have enough coordination to do something like that (which is basically what we are banking on currently), but if it does, we will probably have to step in manually.
Why would the VM even need external network access? Let it have only LAN access to communicate key strokes and host a local mirror for pacstrap/pacman. Also limit the interface to only those two operations.
It will essentially be a war between stupidity, profiteering, computer science nerds installing cryptographically secure jails, and people in the chat trying to make persuasive arguments that yes, in fact, this is the correct command to move on to the next step.
Hopefully people learn some tactics which might be applied in similar situations in their own lives.
"It will essentially be a war between stupidity, profiteering, computer science nerds installing cryptographically secure jails, and people in the chat trying to make persuasive arguments that yes, in fact, this is the correct command to move on to the next step."
Arch is based on binaries so you don't have to spend hours compiling. Surely Ctrl-C is going to "win" after the 4th hour of just watching X compile! :)
Yeah, sorry. I forget I'm on an i7 now, albeit a laptop one. It could easily take 8 times that long on something like an Atom or some sort of ARM. Though I wonder how long it takes on a desktop i7 with an SSD.
I've done both, and they're both pretty easy if you know what you're doing.
The only thing that's a bit more of a pain in the ass in Arch is mirror selection: Arch likes to use really shitty mirrors by default, and I have to waste time commenting out most of the mirrors in the file if I don't want to be stuck with <100kbps downloads, while Gentoo is a lot smarter when it comes to picking mirrors.
Nah. Format the disk, bootstrap your root partition, edit some config files, install your packages, done. If you know what you're doing and have a fast internet connection, you're talking about 10 minutes to a working OS. Unlike Gentoo, which has a days-long compilation step.
You missed setting up a bootloader, which often is the most tricky part, sometimes due to some funny update in the freshest version of the ArchLinux which wasn't fixed yet. Bleeding edge and all.
The main difference between Arch and Gentoo from an installation point of view is that Arch generally doesn't include configuration in its packages. So for every package you install, you have to manually set up the config before it will work. Gentoo often has the config set up for you. In my experience, this often makes Gentoo faster to set up than Arch, even though you are building all the packages. I actually moved to Arch, though, because the lack of configuration means that there are less dependencies in Arch (if you want optional dependencies, you have to configure them yourself). For me, this made Arch a bit more flexible. You can also build all your packages by hand using the Arch Build System (ABS). The one thing from Gentoo that I wish was in Arch is the license manager. I liked the idea that it would keep track of the licenses that I agreed to and warned me if I tried to install a package with a different license.
Really? I didn't find it too difficult, easily done in ~10 minutes. I mean, a Gentoo Stage 3 install is pretty easy these days as well, but I think Arch is still substantially quicker to get running.