Skip to content
This repository has been archived by the owner on Jan 23, 2023. It is now read-only.
/ corefx Public archive

Linux: ProcessName: return script name instead of interpreter program #37294

Merged
merged 6 commits into from
May 16, 2019

Conversation

tmds
Copy link
Member

@tmds tmds commented Apr 30, 2019

@tmds
Copy link
Member Author

tmds commented Apr 30, 2019

@stephentoub @wtgodbe @danmosemsft @krwq ptal

This matches with behavior of previous .NET Core versions, which are returning the script name in Process.ProcessName.

Gnome system monitor uses this value in its 'Process Name' column.

@tmds
Copy link
Member Author

tmds commented Apr 30, 2019

/azp run corefx-outerloop-linux

@danmoseley
Copy link
Member

Any idea what it would take to make macos work?

@tmds
Copy link
Member Author

tmds commented Apr 30, 2019

CI failed:

Pipeline configuration error:
/eng/common/templates/job/job.yml: Could not find /eng/pipelines/helix.yml in repository self hosted on https://api.github.com using commit e59a796. GitHub reported the error, "Not Found"

/azp run corefx-outerloop-linux

Any idea what it would take to make macos work?

Mac user not found between chair and keyboard :)

@tmds
Copy link
Member Author

tmds commented Apr 30, 2019

/azp run

@tmds
Copy link
Member Author

tmds commented Apr 30, 2019

@danmosemsft am I using /azp correctly?

@danmoseley
Copy link
Member

@safern or @ViktorHofer can help with CI

@ViktorHofer ViktorHofer reopened this Apr 30, 2019
@danmoseley
Copy link
Member

@ViktorHofer will that do outer loop though? that was what @tmds was trying.

@safern
Copy link
Member

safern commented Apr 30, 2019

Pipeline configuration error:
/eng/common/templates/job/job.yml: Could not find /eng/pipelines/helix.yml in repository self hosted on https://api.github.com using commit e59a796. GitHub reported the error, "Not Found"

That is an intermitent issue that Github API has and Azure DevOps hits. They're investigating how to fix it or retry when getting the yml file. Now, when hitting this issue we need to retry it manually 😢

@safern
Copy link
Member

safern commented Apr 30, 2019

/azp run corefx-outerloop-linux

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@danmoseley
Copy link
Member

FAilure was dotnet/msbuild#4322

I hit rerun.

{
try
{
Assert.Equal(scriptName, process.ProcessName);
Copy link
Member

@krwq krwq Apr 30, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should this actually return interpreter (whatever the shebang states) and script name in the arguments?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's debatable. I think the main use-case for this property is to help identify processes, then the script name is more useful. Also, when starting a process, scripts can be started the same way as native executables, so it may be unexpected something is actually a script and causes the interpreter to show up here.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

note: this has been returning the script name on Linux so far. I'm adding a test here because that regressed in #37144 (xdg-open is a script).

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Honestly I'd never expect this to return anything else than interpreter name - I think we should match what ps aux does (if it does match then I'm fine with this change), otherwise we're just asking developers to implement their own interop layer to do the right thing. I'd rather add something like ScriptName instead.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ps aux returns the full command line, which includes both the interpreter and the script name.
gnome system monitor (something like Windows process explorer) has a 'Process Name' column which shows the script names.

The ProcessName is the property that helps a user identify a certain process. Having a bunch of bash and python processes is not that helpful (same for Process.GetProcessesByName).

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is Windows a bad analog? It presumably returns cmd.exe.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It presumably returns cmd.exe.

I assume so too.

Is Windows a bad analog?

Unix scripts are more closer to executables than Windows batch files. They are executables (+x bit set) and can be started directly from the Process class (no UseShellExecute required). For a user, there is no difference between a script 'executable' and a native executable. I think it will be unexpected and undesired that the interpreter shows up as the ProcessName.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unix scripts are more closer to executables than Windows batch files.

Fair enough. I don't feel strongly either way. @stephentoub thoughts?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do other languages / frameworks do here from their equivalent types, e.g. Java, node.js, Go, Rust, etc.?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

java's ProcessHandle provides the following:

  • arguments: array of strings (from cmdline)
  • command: string (from exe)
  • commandLine: string (from cmdline)

rust's sysinfo Process provides:

  • name: argv[0] (from cmdline)
  • cmd: string (from cmdline)

I don't think there is a standard way of getting this info in node.js or go. It is suggested to read stdout from ps ..., which includes cmdline.

imo we shouldn't change ProcessName unless additional properties are added to Process that make it possible to identify a certain script (and even then we may want to keep the current behavior).

@wtgodbe
Copy link
Member

wtgodbe commented May 2, 2019

@tmds will this resolve https://github.com/dotnet/corefx/issues/37082 as well? I don't see that test failing in CI here, which is promising.

@wtgodbe
Copy link
Member

wtgodbe commented May 2, 2019

I believe it should resolve https://github.com/dotnet/corefx/issues/35783 as well

Copy link
Member

@wtgodbe wtgodbe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@tmds
Copy link
Member Author

tmds commented May 10, 2019

@tmds will this resolve #37082 as well? I don't see that test failing in CI here, which is promising.
I believe it should resolve #35783 as well

Maybe for the failures on Linux, but not on Windows/OSX.

@tmds
Copy link
Member Author

tmds commented May 10, 2019

/azp help

@azure-pipelines
Copy link

Supported commands
     help:
          Get descriptions, examples and documentation about supported commands
          Example: help "command_name"
     list:
          List all pipelines for this repository using a comment.
          Example: "list"
     run:
          Run all pipelines or a specific pipeline for this repository using a comment. Use
          this command by itself to trigger all related pipelines, or specify a pipeline
          to run.
          Example: "run" or "run pipeline_name"
     where:
          Report back the Azure DevOps orgs that are related to this repository and org
          Example: "where"

See additional documentation.

@tmds
Copy link
Member Author

tmds commented May 10, 2019

/azp list

@azure-pipelines
Copy link

Commenter does not have sufficient privileges for PR 37294 in repo dotnet/corefx

@tmds
Copy link
Member Author

tmds commented May 10, 2019

Commenter does not have sufficient privileges for PR 37294 in repo dotnet/corefx

@stephentoub @wtgodbe can you please trigger an outerloop test run?

@danmoseley
Copy link
Member

danmoseley commented May 10, 2019

@ViktorHofer why did /azp list not work for @tmds?

@danmoseley
Copy link
Member

/azp list

@azure-pipelines
Copy link

CI/CD Pipelines for this repository:
corefx-ci
corefx-outerloop-linux
corefx-outerloop-osx
corefx-outerloop-windows

@danmoseley
Copy link
Member

/azp run corefx-outerloop-linux

@danmoseley
Copy link
Member

/azp run corefx-outerloop-osx

@azure-pipelines
Copy link

Azure Pipelines failed to run 1 pipeline(s).

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@danmoseley
Copy link
Member

/apz run corefx-outerloop-windows

@tmds
Copy link
Member Author

tmds commented May 14, 2019

CI failures are unrelated to the PR.
Per my earlier comment I think we should keep returning the script name.

@danmoseley
Copy link
Member

@wtgodbe look ready?

@wtgodbe
Copy link
Member

wtgodbe commented May 14, 2019

This looks good to me - @krwq @stephentoub were your concerns resolved?

@krwq
Copy link
Member

krwq commented May 15, 2019

fine with me

@wtgodbe wtgodbe merged commit 1b6f45c into dotnet:master May 16, 2019
@karelz karelz added this to the 3.0 milestone May 22, 2019
picenka21 pushed a commit to picenka21/runtime that referenced this pull request Feb 18, 2022
…dotnet/corefx#37294)

* Linux: ProcessName: return script name instead of interpreter program

Fixes https://github.com/dotnet/corefx/issues/37198
Regression by dotnet/corefx#37144

* Add ProcessNameMatchesScriptName test

* ProcessNameMatchesScriptName: don't run on OSX

* LongProcessNamesAreSupported: don't run on Alpine

* Remove ActiveIssue attributes


Commit migrated from dotnet/corefx@1b6f45c
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Test failure: ProcessStart_UseShellExecute_OnUnix_SuccessWhenProgramInstalled(isFolder: False)
8 participants