Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Halp needed with C

Name: Anonymous 2007-12-30 15:01

Hello EXPERT PROGRAMMERS
I need your help with C

So.. I'm codin an IRC bot with C, and when certain conditions are met, it will fork to background. This works fine, but umask spits an warning with gcc and -Wall, even though it works fine on the execution. What's the problem?

As far as I'm aware, I'm not missing any includes and there's nothing dramatically wrong. Care to enlighten me why this happens?

Here's my includes in case I'm missing something:

#include <stdio.h>
#include <sys/socket.h>
#include <sys/types.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <netdb.h>
#include <stdlib.h>
#include <string.h>
#include <malloc.h>
#include <stdarg.h>
#include <unistd.h>
#include <signal.h>
#include <fcntl.h>
#include <time.h>


Here's the fork part:

  if (tofork == 1) {
    pid_t pid;
    pid = fork();
    if (pid < 0)
      exit(1);
    if (pid != 0)
      exit(0);
   
    setsid();
    signal (SIGHUP, SIG_IGN);
    pid = fork();

    if (pid < 0)
      exit(1);
    if (pid != 0)
      exit(0);

    chdir("/tmp");
    umask(0);

    for (i = 0; i < 3; ++i) close(i);
    fd = open("/dev/null", O_RDWR);
    dup(fd);
    dup(fd);
 
  }


Upon compilation:

~/c/wip/ircbot >> gcc -Wall -o bot ircbot.c                    
ircbot.c: In function 'main':
ircbot.c:420: warning: implicit declaration of function 'umask'

Name: Anonymous 2007-12-31 9:18

UMASK(2)                  OpenBSD Programmer's Manual                 UMASK(2)

NAME
     umask - set file creation mode mask

SYNOPSIS
     #include <sys/types.h>
     #include <sys/stat.h>

     mode_t
     umask(mode_t numask);

Fixed.

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List