Bug 7968 - Environment.UserInteractive returns wrong value on Linux
Summary: Environment.UserInteractive returns wrong value on Linux
Status: NEW
Alias: None
Product: Class Libraries
Classification: Mono
Component: System (show other bugs)
Version: 2.10.x
Hardware: PC Linux
: --- normal
Target Milestone: Untriaged
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2012-10-24 10:56 UTC by Eric Lawrence
Modified: 2013-07-08 10:40 UTC (History)
2 users (show)

See Also:
Tags:
Is this bug a regression?: ---
Last known good build:


Attachments
Console/Service app that uses Environment.UserInteractive (1.87 KB, text/plain)
2013-07-08 10:40 UTC, Fritz
Details

Description Eric Lawrence 2012-10-24 10:56:55 UTC
Environment.UserInteractive always returns false on Linux. This causes lots of problems in porting Windows code.

http://lists.ximian.com/pipermail/mono-devel-list/2008-February/026803.html
http://stackoverflow.com/questions/9065065/how-to-detect-if-im-running-in-mono-service
https://groups.google.com/forum/?fromgroups#!topic/ravendb/e6qBJi5qXJc

		/// <summary>
		/// Gets a flag indicating whether the process is in interactive mode
		/// </summary>
		[MonoTODO ("Currently always returns false, regardless of interactive state")]
		public static bool UserInteractive {
			get {
				return false;
			}
		}

If this is desirable for any reason, the Mono documentation should at least be updated.
Comment 1 Fritz 2013-07-08 10:40:37 UTC
Created attachment 4283 [details]
Console/Service app that uses Environment.UserInteractive
Comment 2 Fritz 2013-07-08 10:40:50 UTC
What is the status or comments on this item. I have a console app that needs to be used as windows service and an option to be run in the console. 

To do this, an option is to check "Environment.UserInteractive" if it is true most of the time this means it is run in the console or terminal. If it is false. it is running as a service. With mono it always returns false which, results in the attached program to run incorrectly. This works fine with MS .NET.

I have attached a simple service that can be used as an example.

Note You need to log in before you can comment on or make changes to this bug.