Thread: change argv[0] after fork

  1. #1
    Registered User
    Join Date
    Dec 2005
    Posts
    3

    change argv[0] after fork

    can someone tell me how can I change the name of a process after a for();
    normally it's done by changing argv[0], but how should it be done in a new process ?

  2. #2
    Sr. Software Engineer filker0's Avatar
    Join Date
    Sep 2005
    Location
    West Virginia
    Posts
    235
    I'd suppose that it should work the same way in the new process as it does in the old process. The forked process gets its own copy of argv[].
    Insert obnoxious but pithy remark here

  3. #3
    C/C++Newbie Antigloss's Avatar
    Join Date
    May 2005
    Posts
    216
    Maybe you could do something like this

    Code:
    #include <stdio.h>
    
    int main(int argc, char *argv[])
    {
        argv[0] = "vvvv";
        
        printf("%s\n", argv[0]);    
     
        return 0;
    }

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. c++builder6 change form names problem
    By Leite33 in forum C++ Programming
    Replies: 2
    Last Post: 06-09-2008, 08:20 AM
  2. how to change static char* and not lose mem ?
    By jabka in forum C Programming
    Replies: 15
    Last Post: 09-07-2007, 05:33 PM
  3. Change Value in an array
    By beginner999 in forum C Programming
    Replies: 3
    Last Post: 01-18-2003, 07:16 AM
  4. Replies: 2
    Last Post: 11-08-2002, 03:22 AM
  5. Replies: 2
    Last Post: 09-04-2001, 02:12 PM