Changeset ff924dbc0fa20c7631c2a07af0a1c36d571a5e71

Show
Ignore:
Timestamp:
30/06/06 18:34:46 (2 years ago)
Author:
Pavlov Konstantin <thresh@videolan.org>
git-committer:
Pavlov Konstantin <thresh@videolan.org> 1151685286 +0000
git-parent:

[d17c2e5f50a30c7f73821a70e7a0f8ae0b495e9d]

git-author:
Pavlov Konstantin <thresh@videolan.org> 1151685286 +0000
Message:

support for creating pid files when going daemon mode.
Someone should really review it as it is my first experience in C.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • include/main.h

    rdea4749 rff924db  
    9393    char *                 psz_userdir;             /* user's home directory */ 
    9494    char *                 psz_configfile;        /* location of config file */ 
     95    char *                 psz_pidfile; 
    9596 
    9697    /* Fast memcpy plugin used */ 
  • src/libvlc.c

    rbaacaea rff924db  
    419419 
    420420        p_vlc->p_libvlc->b_daemon = VLC_TRUE; 
     421 
     422        /* lets check if we need to write the pidfile */ 
     423        p_vlc->psz_pidfile = config_GetPsz( p_vlc, "pidfile" ); 
     424 
     425        msg_Dbg( p_vlc, "p_vlc->psz_pidfile is %s", p_vlc->psz_pidfile ); 
     426 
     427        if( p_vlc->psz_pidfile != NULL ) 
     428        { 
     429            pid_t i_pid; 
     430            FILE *pidfile; 
     431             
     432            i_pid = getpid(); 
     433 
     434            msg_Dbg( p_vlc, "our PID is %d, writing it to %s", i_pid, p_vlc->psz_pidfile ); 
     435             
     436            pidfile = utf8_fopen( p_vlc->psz_pidfile,"w" ); 
     437            if( pidfile != NULL ) 
     438            { 
     439                utf8_fprintf( pidfile, "%d", (int)i_pid ); 
     440                fclose( pidfile ); 
     441            } 
     442            else 
     443            { 
     444                msg_Err( p_vlc, "Cannot open pid file for writing: %s, error: %s", p_vlc->psz_pidfile, strerror(errno) ); 
     445            } 
     446        } 
    421447 
    422448#else 
  • src/libvlc.h

    r06b57a5 rff924db  
    835835#define DAEMON_LONGTEXT N_( \ 
    836836     "Runs VLC as a background daemon process.") 
     837 
     838#define PIDFILE_TEXT N_("Write process id to file") 
     839#define PIDFILE_LONGTEXT N_( \ 
     840       "Writes proccess id into specified file.") 
    837841 
    838842#define FILE_LOG_TEXT N_( "Log to file" ) 
     
    15921596    add_bool( "daemon", 0, NULL, DAEMON_TEXT, DAEMON_LONGTEXT, VLC_TRUE ); 
    15931597        change_short('d'); 
     1598 
     1599    add_string( "pidfile", NULL, NULL, PIDFILE_TEXT, PIDFILE_LONGTEXT, 
     1600                                       VLC_FALSE ); 
    15941601#endif 
    15951602