Changeset ff924dbc0fa20c7631c2a07af0a1c36d571a5e71
- 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
| rdea4749 |
rff924db |
|
| 93 | 93 | char * psz_userdir; /* user's home directory */ |
|---|
| 94 | 94 | char * psz_configfile; /* location of config file */ |
|---|
| | 95 | char * psz_pidfile; |
|---|
| 95 | 96 | |
|---|
| 96 | 97 | /* Fast memcpy plugin used */ |
|---|
| rbaacaea |
rff924db |
|
| 419 | 419 | |
|---|
| 420 | 420 | 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 | } |
|---|
| 421 | 447 | |
|---|
| 422 | 448 | #else |
|---|
| r06b57a5 |
rff924db |
|
| 835 | 835 | #define DAEMON_LONGTEXT N_( \ |
|---|
| 836 | 836 | "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.") |
|---|
| 837 | 841 | |
|---|
| 838 | 842 | #define FILE_LOG_TEXT N_( "Log to file" ) |
|---|
| … | … | |
| 1592 | 1596 | add_bool( "daemon", 0, NULL, DAEMON_TEXT, DAEMON_LONGTEXT, VLC_TRUE ); |
|---|
| 1593 | 1597 | change_short('d'); |
|---|
| | 1598 | |
|---|
| | 1599 | add_string( "pidfile", NULL, NULL, PIDFILE_TEXT, PIDFILE_LONGTEXT, |
|---|
| | 1600 | VLC_FALSE ); |
|---|
| 1594 | 1601 | #endif |
|---|
| 1595 | 1602 | |
|---|