public static void Attach(Entry plugin)
            {
                try
                {
                    if (!_exiting && !_attached)
                    {
                        _attached = true;
                        // Catch SIGINT, SIGUSR1 and SIGTERM
                        UnixSignal[] signals = new UnixSignal[]
                        {
                            new UnixSignal(Signum.SIGINT),
                            new UnixSignal(Signum.SIGUSR1),
                            new UnixSignal(Signum.SIGTERM)
                        };

                        (_signal_thread = new Thread(() =>
                        {
                            System.Threading.Thread.CurrentThread.Name = "SIG";
                            try
                            {
                                while (!Terraria.Netplay.disconnect && _attached)
                                {
                                    // Wait for a signal to be delivered
                                    if (UnixSignal.WaitAll(signals, 250))
                                    {
                                        if (!Terraria.Netplay.disconnect && _attached)
                                        {
                                            _attached = false;
                                            OTA.Logging.ProgramLog.Log("Server received Exit Signal");

                                            Terraria.IO.WorldFile.saveWorld(false);
                                            Terraria.Netplay.disconnect = true;
                                        }
                                    }
                                }

                                OTA.Logging.ProgramLog.Debug.Log("Sigterm thread exiting");
                            }
                            catch (System.Exception e)
                            {
                                OTA.Logging.ProgramLog.Log(e, "Sigterm exception");
                            }
                        })).Start();
                    }
                }
                catch
                {
                    OTA.Logging.ProgramLog.Log("Failed to attach Sigterm listener");
                }
            }