Interrupting a long MacPorts installation - macos

I'm currently installing qt4-mac and it's taking forever to build. I've searched around and I've discovered that it's going to take anywhere from 2-5 hours to install.
Is there a way to interrupt this installation process and if so do I need to do some clean-up afterwards?

Have you tried using control+c?
Also, I'm not entirely sure about cleanup, but according to the MacPorts docs, the command sudo port -fp uninstall --follow-dependents [your port name here] should help (this page is about uninstalling MacPorts itself, but it's the same command). I'm not sure how MacPorts treats interrupted installations and if it treats "half-installed" items as uninstallable, but it's worth a try.

This is an old thread, but I'd like to share my personal opinion on this.
Once upon a time (two years ago I guess, not sure about the current state of affairs) I interrupted a MacPorts update (sudo port upgrade outdated) with not Ctrl+C (roughly SIGINT), but rather SIGKILL, since I was running into some trouble with the hardware at that time. I ended up with a completely broken install that defied all efforts of clean-up or recovery, and I ended up restoring a full backup of /opt/local.
I never dare to interrupt MacPorts install/upgrade since then, even with Ctrl+C's.
The moral of the story is: interrupting MacPorts installation process could be potentially pretty dangerous. Leave it alone if it is simply running for a long time (sometimes building does take forever). If you do believe it is hanging rather than actually building, make sure you have a backup, and proceed with caution (of course, it's too late to back up when you are already running the install).

I also would like to chime in. I think a good practice is to watch where you are in the installation before Ctrl+Cing, then clean the dependency you were on and redo the main install later. For example, I was installing kdenlive and killed it in the middle of the virtuoso (one of many dependencies) install. Later, I did a sudo port -v selfupdate, then a port clean virtuoso, then started the kdenlive install again with sudo port install kdenlive. This seems to be a decent way to go; it cruised through the first part and picked up at normal speed when it got to virtuoso.

Don't press Ctrl+C
Building on the answer by 4ae1e1, while (s)he interrupted the process sending a SIGKILL signal, I interrupted it sending an actual SIGINT signal, i.e. the usual Ctrl+C, and now no MacPorts app are working so far.
So I completely agree with 4ae1e1.
If you need your machine
If you need to suspend the installation, e.g. because you need your CPU to be available for other things, to send a SIGSTOP signal instead, in order to pause the installation.
kill -STOP installationPIDs
Once you are ready to resume it, you can send a SIGCONT signal and you can complete it.
kill -CONT installationPIDs
You should easily find the PIDs of the installation process, for example you can just run htop and look among the processes using most of the CPU.
If you change your mind about an installation
Even if you change your mind and you do not want that port/package installed anymore, I strongly recommend to just complete the installation (pausing it when needed as suggested below) and just uninstall the port/package afterwards. It sounds like a waste of time, but it is the safest thing to do.

Related

PDB debugger stability questions

I am using either pdb or ipdb for debugging my python code. However whenever I am using set_trace() I can typically run a handful of lines of code to test but it eventually freezes while I am typing. I kill the python process and have to re-run the entire process from the start - which usually kills about 5-10 minutes of data processing time to get back to where I was.
I am using an anaconda build with python 2.7.
The only anomaly I have is that I needed to run
conda install -c conda-forge psycopg2=2.6.2 in order to be able to use psycopg2. I have been ignoring it for the last two months but realize that it isn't an acceptable work flow.
Any thoughts to help resolve would be appreciated.
Resolved it.
I still don't know why this behavior is happening but if I press caps lock twice while it is frozen - it unlocks the set_trace. Don't ask me why but it works.

Search & Destroy Rouge Process in OSX

INFO: I installed SymformSync the other day, a distributed cloud storage system, but deleted it again the same day. (I like the idea, but it's not suitable for someone on a laptop like me.) However, there's a process symformsync that keeps popping up and consuming pretty heavily on the CPU. I deleted the application, but this process still keeps popping up! Needless to say, I don't appreciate not having control over the processes on my own CPU!
Q: How do I find this process that keeps starting up by itself, and how do I delete it?
Answer from Symform:
Thank you for contacting Symform support. I understand that you are needing the instructions to remove Symform from your Mac.
Here is the information:
Access the Terminal program on your Mac, by going to the search tool in the upper right-hand corner, and entering in Terminal.
Once Terminal is open, enter in the following command, depending on what you want to do:
Normal uninstall will only stop the services and remove the software. It will leave the service configuration and log files in place.
sudo /Library/Application\ Support/Symform/scripts/uninstall
To completely remove all aspects of the Symform software, configuration, and logs, a purging operation is available as well. This will remove any synchronization and contribution supporting files and directories too.
sudo /Library/Application\ Support/Symform/scripts/uninstall --purge
You will need to enter in your Mac password when running either of these commands.

How to handle abnormal program termination in Perl on Windows

I have a Perl program on Windows that needs to execute cleanup actions on exit. I wrote a signal handler using sigtrap, but it doesn't always work. I can intercept Ctrl-C, but if the machine is rebooted or the program is killed some other way, neither the signal handler nor the END block are run. I've read that Windows doesn't really have signals, and signal handling on windows is sort of a hack in Perl. My question is, how can I handle abnormal termination the Windows way? I want to run my cleanup code regardless of how or why the program terminates (excluding events that can't be caught). I've read that Windows uses events instead of signals, but I can't find information on how to deal with Windows events in Perl.
Unfortunately, I don't have the authority to install modules from CPAN, so I'll have to use vanilla ActiveState Perl. And to make things even more interesting, most of the machines I'm using only have Perl 5.6.1.
Edit: I would appreciate any answers, even if they require CPAN modules or newer versions of Perl. I want to learn about Windows event handling in Perl, and any information would be welcome.
In all operating systems, you can always abruptly terminate any program. Think of kill -9 command in Unix/Linux. You do that on any program, and it stops instantly. No way to trap it. No way for the program to request a few more operating system cycles for a clean up.
I'm not up on the difference between Unix and Windows signals, but you can imagine why each OS must allow what we call in Unix SIGKILL - a sure and immediate way to kill any program.
Imagine you have a buggy program that intercepts a request to terminate (a SIGTERM in Unix), and it enters a cleanup phase. Instead of cleaning up, the program instead gets stuck in a loop that requests more and more memory. If you couldn't pull the SIGKILL emergency cord, you'd be stuck.
The ultimate SIGKILL, of course is the plug in the wall. Pull it, and the program (along with everything else) comes to a screeching halt. There's no way your program can say "Hmm... the power is out and the machines has stopped running... Better start up the old cleanup routine!"
So, there's no way you can trap every program termination signal, and, your program will have to account for that. What you can do is see if your program needs to do a cleanup before running. On Windows, you can put an entry in the registry when your program starts up, and remove it when it shuts down and does a cleanup. In Unix, you can put a file or directory name starting wit a period in the $ENV{HOME} directory.
Back in the 1980s, I wrote accounting software for a very proprietary OS. When the user pressed the ESCAPE button, we were suppose return immediately to the main menu. If the user was entering an order, and took stuff out of inventory, the transaction would be incomplete, and inventory would be showing the items as being sold even though the order was incomplete. The solution was to check for these incomplete orders the next time someone entered an order, and back out the changes in inventory before entering the new order. Your program may have to do something similar.

How to Safely Force Shutdown of Mac

What I want
I'm developing a little app to force me to only work at certain times of day - I need something to force me to stop working in the evenings so I can be more effective in the day.
The option within OS X to shut down my machine at a certain time is too easy to cancel. And you can always log back in afterwards.
I want my app to quit all applications whether they have unsaved work or not.
What I've tried
I thought of killing the loginwindow process, but I've read that this can cause data corruption.
I've come across the shutdown command - I'm using sudo shutdown -h +0 to shutdown immediately. This appears to be just the ticket, but I'm worried that it might cause data corruption if, say, Disk Utility is doing some kind of scan.
Is the shutdown command safe?
Can the shutdown command cause corruption? Or is it safe to use? Is there a better way of forcing shutdown safely?
Use AppleScript to tell application "System Events" to shut down.
The shutdown command sends running processes a signal to terminate, giving them a chance to do clean up work, if needed. So generally, when an application receives this signal (SIGTERM(inate)) it should wrap up and exit.
IIRC in Snow Leopard (10.6) Apple added something called fast-shutdown (or similar) which will send processes that have been flagged as being ok with it a SIGKILL signal, shutting them down without chance for cleanup work. This is supposed to make shutdown faster. The default is that applications still get SIGTERM and have to opt-in for SIGKILL; and they can mark themselves as "dirty", i. e. having unsaved work and do not want to be killed forcibly.
So while shutting down in the middle of a disk utility run will abort whatever disk utility is doing, IMHO it would not cause data corruption in general. However depending on the operation you are currently running, you could end up with an incomplete disk image or a half-formatted partition. Maybe you want to refrain from using it when you know the end of your configured work time is coming close.
Using cron to schedule the shutdown is a viable option if you want it to happen at a specified time. If you want it to happen after a certain amount of time after you log in, you could use the number parameter to shutdown to specify say 8 hours from now.
If you want to lose unsaved work then shutdown -h is your only answer.
However, anyone who has debugged a full-screen app on OS X knows that is it very easy (some say too easy) for an app to capture the screen and render the computer essentially useless (without SSHing from another computer to kill the process.) That's another alternative.
the recommended way to schedule a shutdown of your computer on a regular basis is in the system preferences -> Energy Saver panel. Click on the "schedule" button in the lower right hand corner. the rest is self explanatory...
Forcing your computer to shut down (and discard any unsaved work) doesn't sound like a good idea to me. Wouldn't it be easier and safer to just set an alarm clock to remind yourself when you should stop working, and walk away from your computer when it rings? (That's what I do.)
Edit: That might have come across as a bit rude, which was not my intention at all. (I had no intention of making fun of your question or anything like that.) I just think that this would be a better solution to this problem :)
Maybe cron is installed on your computer? It's wonderful =)

windows installation hang

How can I find what's hanging all new installations on a Windows box?
While testing an installation script on Windows (XP Pro, if it matters) I've run into a situation wherein any and all attempts to install anything on the system hang waiting on who knows what. When the system is restarted, all queued up attempts at installation then go through their exit paths with pop-ups that report the installation is being aborted due to system shutdown having been requested. Of course, reboots do not cure the problem. The system otherwise runs fine.
So... How can I determine what part of the OS I've wedged? (Something in the registry, I suppose, but I'm a real greenhorn when it comes to Windows.) Most likely, something from a preceding install attempt went awry and is now blocking even though I saw no errors reported. Once I figure this out, I want to put in a check for this sort of thing, possibly at both ends of my install scripts, if that seems reasonable.
Thanks for your input.
UPDATE:
Unfortunately for me, rebuilding from scratch to get to the point the system's in now is about 9 hours. I'd like to unwedge it from where it is now rather than reload (again). Procmon seems great but I haven't got SP2 installed, only SP1! -frown- So, other ideas are welcome.
I assume you've tried logging the install to see where things go wrong?
Try rolling back to before things went wrong using "System Restore", if that doesn't solve it and the MSI log files show nothing useful then I'd take the plunge and reload before wasting any more time on it.
That said, if you're developing installers then taking an image of this PC in it's crappy state could be a worthwhile exercise. Some point in the future when you have more time to debug you can try and figure out what the problem is.
P.S. I'm assuming you're asking this question from the point of view of someone developing an installer and not as a tech-support question... otherwise this question should probably be closed as not-programming-related ;)
Try using Procmon to figure out where the installer is having problems, if you set a filter it will report all file and registry activity for that process.

Resources