# Application Name / Process Name

**URL:** <https://www.ruby-forum.com/t/application-name-process-name/188996>\
**Category:** Ruby\
**Created:** [May 21, 2010, 3:55pm UTC](https://www.ruby-forum.com/t/application-name-process-name/188996 "2010-05-21T15:55:27Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![superfly](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/48db29/32.png) [@superfly](https://www.ruby-forum.com/u/superfly)\
**Post date:** [May 21, 2010, 3:55pm UTC](https://www.ruby-forum.com/t/application-name-process-name/188996/1 "2010-05-21T15:55:27Z")

</div>

Is there any way to set the application name or process name that  
appears in task manager for a program?

---

<div class="post-metadata">

**Author:** ![superfly](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/48db29/32.png) [@superfly](https://www.ruby-forum.com/u/superfly)\
**Post date:** [May 21, 2010, 4:18pm UTC](https://www.ruby-forum.com/t/application-name-process-name/188996/2 "2010-05-21T16:18:32Z")

</div>

On May 21, 2010, at 9:55 AM, 12345678 123456789 wrote:

> ## Is there any way to set the application name or process name that appears in task manager for a program?
> 
> Posted via [http://www.ruby-forum.com/](http://www.ruby-forum.com/).

$0 = “This is my program\0”

But you might have trouble if you want to set the name to something  
longer than the original program + args. (I.e., $0.length

You can also run into trouble if a process monitor (e.g., monit) is  
relying on the process name.

-Rob

Rob B.  
[http://agileconsultingllc.com](http://agileconsultingllc.com)  
removed\_email\_address@domain.invalid

> **[Launch Scout Custom Software Development & Software Consulting](https://launchscout.com/)**
>
> We solve digital problems through custom software development and design for the web—apps, mobile, desktop and devices.

removed\_email\_address@domain.invalid

---

<div class="post-metadata">

**Author:** ![superfly](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/48db29/32.png) [@superfly](https://www.ruby-forum.com/u/superfly)\
**Post date:** [May 21, 2010, 4:26pm UTC](https://www.ruby-forum.com/t/application-name-process-name/188996/3 "2010-05-21T16:26:00Z")

</div>

Rob B. wrote:

> On May 21, 2010, at 9:55 AM, 12345678 123456789 wrote:
> 
> > ## Is there any way to set the application name or process name that appears in task manager for a program?
> > 
> > Posted via [http://www.ruby-forum.com/](http://www.ruby-forum.com/).
> 
> $0 = “This is my program\0”
> 
> But you might have trouble if you want to set the name to something  
> longer than the original program + args. (I.e., $0.length
> 
> You can also run into trouble if a process monitor (e.g., monit) is  
> relying on the process name.
> 
> -Rob
> 
> Rob B.  
> [http://agileconsultingllc.com](http://agileconsultingllc.com)  
> removed\_email\_address@domain.invalid  
> [http://gaslightsoftware.com](http://gaslightsoftware.com)  
> removed\_email\_address@domain.invalid

Is there something I need to require at the beginning of my code because  
I tried this when I googled the answer and it doesn’t work. I think that  
only applies to Ruby on Rails.

Here are the first few lines of my code:

$defout.sync=true

require ‘uri’  
require ‘net/http’  
require ‘FileUtils’  
require ‘date’  
require ‘yaml’

$0 = “ProgramName”

---

<div class="post-metadata">

**Author:** ![superfly](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/48db29/32.png) [@superfly](https://www.ruby-forum.com/u/superfly)\
**Post date:** [May 21, 2010, 4:49pm UTC](https://www.ruby-forum.com/t/application-name-process-name/188996/4 "2010-05-21T16:49:34Z")

</div>

On May 21, 2010, at 10:26 AM, TJ nonstickglue wrote:

> > $0 = “This is my program\0”  
> > [http://agileconsultingllc.com](http://agileconsultingllc.com)
> 
> ## $0 = “ProgramName”
> 
> Posted via [http://www.ruby-forum.com/](http://www.ruby-forum.com/).

Nothing special  
[ruby-1.8.6] :Users/rab $ ruby -e ‘$0=“Here I am\0”;sleep 60’ & ps ww  
[1] 70676  
PID TT STAT TIME COMMAND  
62343 s000 S+ 0:00.28 -bash  
70613 s001 S 0:00.12 -bash  
70676 s001 R 0:00.00 Here I am

But you do need to include the NUL at the end “\0” I believe.

-Rob

Rob B.  
[http://agileconsultingllc.com](http://agileconsultingllc.com)  
removed\_email\_address@domain.invalid

> **[Launch Scout Custom Software Development & Software Consulting](https://launchscout.com/)**
>
> We solve digital problems through custom software development and design for the web—apps, mobile, desktop and devices.

removed\_email\_address@domain.invalid

---

<div class="post-metadata">

**Author:** ![superfly](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/48db29/32.png) [@superfly](https://www.ruby-forum.com/u/superfly)\
**Post date:** [May 24, 2010, 2:01am UTC](https://www.ruby-forum.com/t/application-name-process-name/188996/5 "2010-05-24T02:01:52Z")

</div>

Looks like it does with one-liner.  
ruby -e ‘$0=“Here I am\0”;puts Kernel::fork;sleep 60’ & ps ww

Must be a keyboard thing here…

MarkT

On Mon, May 24, 2010 at 9:46 AM, Mark T [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> Should this survive a 1.8.7 fork?

MarkT

---

<div class="post-metadata">

**Author:** ![superfly](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/48db29/32.png) [@superfly](https://www.ruby-forum.com/u/superfly)\
**Post date:** [May 24, 2010, 1:47am UTC](https://www.ruby-forum.com/t/application-name-process-name/188996/6 "2010-05-24T01:47:14Z")

</div>

Should this survive a 1.8.7 fork?

MarkT
