Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Process Name Change? #9957

Closed
howard4086 opened this issue Jan 29, 2015 · 10 comments
Closed

Process Name Change? #9957

howard4086 opened this issue Jan 29, 2015 · 10 comments
Assignees

Comments

@howard4086
Copy link

Is there any way to change the name of a Julia process? I am using Julia to run a few different optimization processes, and it would be nice if they didn't all have the same "julia.exe" name in the task manager so I can more easily monitor them.

Thanks.

@StefanKarpinski
Copy link
Member

You can call whatever C API Windows has to change process names. It might be nice to provide a consistent cross-platform API for this that works similarly on both UNIX and Windows.

@vtjnash
Copy link
Member

vtjnash commented Jan 29, 2015

Doesn't libuv have a function for doing this?

@ihnorton
Copy link
Member

055dcdd works on Windows (gui window title changes); is a no-op on linux; should work on BSD.

@vtjnash
Copy link
Member

vtjnash commented Jan 30, 2015

on linux, it'll call prctl:

       PR_SET_NAME (since Linux 2.6.9)
              Set  the  name of the calling thread, using the value in the location pointed to by (char *) arg2.  The name can be up to 16 bytes long, and should be null-terminated
              if it contains fewer bytes.  This is the same attribute that can be set via pthread_setname_np(3) and retrieved using pthread_getname_np(3).  The attribute  is  like‐
              wise accessible via /proc/self/task/[tid]/comm, where tid is the name of the calling thread.

@ihnorton
Copy link
Member

Doesn't seem to do anything user-visible on my system. No change in top, ps, etc.

@vtjnash
Copy link
Member

vtjnash commented Jan 30, 2015

how about cat /proc/self/task/*/comm?

@ihnorton
Copy link
Member

That doesn't help because the thread there is called cat.

julia> Base.set_process_title("foo")

julia> let d = "/proc/self/task/"
           for dd in readdir(d)
               readall(open(joinpath(d,dd,"comm"))) |> show
           end
       end
"julia\n""julia\n""julia\n""julia\n"

@vtjnash
Copy link
Member

vtjnash commented Jan 30, 2015

you're right, that doesn't seem to work

shell> cat /proc/$(getpid())/task/*/comm
julia
julia
julia
julia
julia
julia
julia
julia

julia> Base.set_process_title("foo")

shell> cat /proc/$(getpid())/task/*/comm
julia
julia
julia
julia
julia
julia
julia
julia

@vtjnash
Copy link
Member

vtjnash commented Jan 30, 2015

apparently we're missing a call to uv_setup_args that should be happening, probably in _julia_init:

julia> ccall(:uv_setup_args, Ptr{Ptr{Uint8}}, (Cint, Ptr{Ptr{Uint8}}), 1, ["foo"])
Ptr{Ptr{UInt8}} @0x0000000003291ff0

julia> Base.get_process_title()
"foo"

julia> Base.set_process_title("bar")

julia> Base.get_process_title()
"bar"

shell> cat /proc/$(getpid())/task/*/comm
bar
julia
julia
julia
julia
julia
julia
julia

@vtjnash vtjnash reopened this Jan 30, 2015
@ihnorton ihnorton self-assigned this Feb 18, 2015
@ihnorton
Copy link
Member

This works on windows, but fixing on linux is blocked on #9482 right now. Assigning to myself so I remember to change it eventually.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants