Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1102493
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T01:11:42+00:00 2026-05-17T01:11:42+00:00

When you type ps aux the ps command shows command arguments that the program

  • 0

When you type “ps aux” the ps command shows command arguments that the program was run with. Some programs change this as a way of indicating status. I’ve tried changing argv[] fields and it doesn’t seem to work. Is there a standard way to set the command line arguments so that they appear when the user types ps?

That is, this doesn’t work:

int main(int argc,char **argv)
{
    argv[0] = "Hi Mom!";
    sleep(100);
}

09:40 imac3:~$ ./x &
[2] 96087
09:40 imac3:~$ ps uxp 96087 
USER      PID  %CPU %MEM      VSZ    RSS   TT  STAT STARTED      TIME COMMAND
yv32      96087   0.0  0.0  2426560    324 s001  S     9:40AM   0:00.00 ./x
09:40 imac3:~$ cat x.c
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-17T01:11:42+00:00Added an answer on May 17, 2026 at 1:11 am

    You had the right idea, but you don’t change the pointers in argv[n], you must change the string pointed to by argv[0] itself:

    #include <string.h>
    #include <unistd.h>
    
    int main(int argc,char **argv)
    {
        size_t maxlen = strlen(argv[0]);
    
        memset(argv[0], 0, maxlen);
        strncat(argv[0], "Hi Mom!", maxlen);
        pause();
    
        return 0;
    }
    

    (Note that whether or not this actually changes the command name shown by ps is system-dependent).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Alright, I know that Scala allwos no aux cons type params. What if I
The type of this function is T -> (T -> U) -> U .
System.Type contains an UnderlyingSystemType property. MSDN states that it: Indicates the type provided by
What is wrong with this program? #include <memory> #include <vector> int main() { std::vector<std::unique_ptr<int>>
I'm new to the Boost.MPL library, and have some beginners-problems Look at this sample:
I'm having problems in using message queues in this program it is supposed to
I had this problem a long time ago and recently I got some clues
This is the shortest of two forms that wont send data to the database,
Type erasure - is that how you call it? How boost::shared_ptr stores its deleter
type SQLConn = val mutable private connection : string option member this.Connection with get()

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.