Find the answer to your Linux question:
Results 1 to 3 of 3
Is there a way to restart dhcp through c? I want to do the equivalent of 'dhcpcd restart' through c. I figure there has to be a way, but I ...
  1. #1
    Just Joined!
    Join Date
    Aug 2007
    Posts
    9

    Restarting DHCP from C

    Is there a way to restart dhcp through c? I want to do the equivalent of 'dhcpcd restart' through c. I figure there has to be a way, but I can't figure out how. Any help would be appreciated. Thanks.

  2. #2
    Linux Enthusiast likwid's Avatar
    Join Date
    Dec 2006
    Location
    MA
    Posts
    649
    You use the system() to do things like this.
    So something like:
    Code:
    statRet = system("/sbin/service dhcpd restart");
    
    if (statRet != 0) fprintf(stderr, "Error restarting dhcpd\n");
    System returns the status of the process it forks. man 3 system is your friend. Note that restarts the dhcpd, the server. If you mean your dhcp client, it's probably dhcpcd.

  3. #3
    Just Joined!
    Join Date
    Aug 2007
    Posts
    9
    cool thank you.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
...