[controller] SetProcessName belongs to SS main class
This commit is contained in:
parent
13c9e53c87
commit
0d3b7ee6e9
|
@ -15,14 +15,11 @@
|
||||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
using Mono.Unix;
|
using Mono.Unix;
|
||||||
using Mono.Unix.Native;
|
|
||||||
using SparkleLib;
|
using SparkleLib;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Runtime.InteropServices;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
|
|
||||||
namespace SparkleShare {
|
namespace SparkleShare {
|
||||||
|
@ -64,8 +61,6 @@ namespace SparkleShare {
|
||||||
public SparkleController ()
|
public SparkleController ()
|
||||||
{
|
{
|
||||||
|
|
||||||
SetProcessName ("sparkleshare");
|
|
||||||
|
|
||||||
InstallLauncher ();
|
InstallLauncher ();
|
||||||
EnableSystemAutostart ();
|
EnableSystemAutostart ();
|
||||||
|
|
||||||
|
@ -622,32 +617,6 @@ namespace SparkleShare {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Sets the unix process name to 'sparkleshare' instead of 'mono'
|
|
||||||
private void SetProcessName (string name)
|
|
||||||
{
|
|
||||||
|
|
||||||
try {
|
|
||||||
|
|
||||||
if (prctl (15, Encoding.ASCII.GetBytes (name + "\0"), IntPtr.Zero, IntPtr.Zero, IntPtr.Zero) != 0) {
|
|
||||||
|
|
||||||
throw new ApplicationException ("Error setting process name: " +
|
|
||||||
Mono.Unix.Native.Stdlib.GetLastError ());
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
} catch (EntryPointNotFoundException) {
|
|
||||||
|
|
||||||
Console.WriteLine ("SetProcessName: Entry point not found");
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// Strange magic needed by SetProcessName
|
|
||||||
[DllImport ("libc")]
|
|
||||||
private static extern int prctl (int option, byte [] arg2, IntPtr arg3, IntPtr arg4, IntPtr arg5);
|
|
||||||
|
|
||||||
// Quits the program
|
// Quits the program
|
||||||
public void Quit ()
|
public void Quit ()
|
||||||
{
|
{
|
||||||
|
|
|
@ -16,12 +16,15 @@
|
||||||
|
|
||||||
using Gtk;
|
using Gtk;
|
||||||
using Mono.Unix;
|
using Mono.Unix;
|
||||||
|
using Mono.Unix.Native;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
|
using System.Runtime.InteropServices;
|
||||||
using SparkleLib;
|
using SparkleLib;
|
||||||
using SparkleLib.Options;
|
using SparkleLib.Options;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
namespace SparkleShare {
|
namespace SparkleShare {
|
||||||
|
|
||||||
|
@ -42,6 +45,8 @@ namespace SparkleShare {
|
||||||
public static void Main (string [] args)
|
public static void Main (string [] args)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
SetProcessName ("sparkleshare");
|
||||||
|
|
||||||
// Use translations
|
// Use translations
|
||||||
Catalog.Init (Defines.GETTEXT_PACKAGE, Defines.LOCALE_DIR);
|
Catalog.Init (Defines.GETTEXT_PACKAGE, Defines.LOCALE_DIR);
|
||||||
|
|
||||||
|
@ -138,6 +143,33 @@ namespace SparkleShare {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Sets the unix process name to 'sparkleshare' instead of 'mono'
|
||||||
|
private static void SetProcessName (string name)
|
||||||
|
{
|
||||||
|
|
||||||
|
try {
|
||||||
|
|
||||||
|
if (prctl (15, Encoding.ASCII.GetBytes (name + "\0"), IntPtr.Zero, IntPtr.Zero, IntPtr.Zero) != 0) {
|
||||||
|
|
||||||
|
throw new ApplicationException ("Error setting process name: " +
|
||||||
|
Mono.Unix.Native.Stdlib.GetLastError ());
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
} catch (EntryPointNotFoundException) {
|
||||||
|
|
||||||
|
Console.WriteLine ("SetProcessName: Entry point not found");
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Strange magic needed by SetProcessName
|
||||||
|
[DllImport ("libc")]
|
||||||
|
private static extern int prctl (int option, byte [] arg2, IntPtr arg3, IntPtr arg4, IntPtr arg5);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue