WSL icon indicating copy to clipboard operation
WSL copied to clipboard

Unable to calculate process start time

Open ericeil opened this issue 10 years ago • 2 comments

Build: rs_prerelease 14905

Two ways to repro this:

  1. Run the following under .NET Core:
using System;

namespace ConsoleApplication
{
    public class Program
    {
        public static void Main(string[] args)
        {
            var p = System.Diagnostics.Process.GetCurrentProcess();
            Console.WriteLine(p.StartTime.ToString("F"));
        }
    }
}

Expected output: something close to the current time. Actual output: I see a time in the far future: Sunday, April 11, 2432 7:11:56 AM.

The ps command reports similar results:

ps -o lstart,args
Sat Apr 10 05:37:01 2432 /bin/bash
Sat Apr 10 08:17:55 2432 /bin/sh -c export LANG=en_US.UTF-8; export LC_ALL=en_US.UTF-8; . /tmp/tmp5bfd075d549648af8a1b3c
Sat Apr 10 08:17:56 2432 bash /home/ericeil/src/corefx/bin/tests/Unix.AnyCPU.Debug/System.IO.Pipes.Tests/netcoreapp1.0/R
Sat Apr 10 08:18:01 2432 ./corerun xunit.console.netcore.exe System.IO.Pipes.Tests.dll -xml testResults.xml -notrait Ben
Sat Apr 10 09:04:31 2432 /bin/bash
Sun Apr 11 07:03:40 2432 ps -o lstart,args

Note that all processes appear to have been started in the year 2432.

I'm not sure how ps calculates this. .NET calculates it from the "starttime" field of /proc/[pid]/stat and the result of clock_gettime(CLOCK_MONOTONIC, ...).

ericeil avatar Aug 23 '16 20:08 ericeil

Thanks for reporting this one. Filed a bug against it.

Good catch.

russalex avatar Aug 24 '16 20:08 russalex

Thanks for reporting, checked in a fix for that.

misenesi avatar Nov 04 '16 19:11 misenesi