public
Description: Lightweight console-based radio player for Last.FM radio streams.
Homepage: http://nex.scrapping.cc/code/shell-fm/
Clone URL: git://github.com/jkramer/shell-fm.git
Click here to lend your support to: shell-fm and make a donation at www.pledgie.com !
Fixed daemonizing issue: true TTY detaching

Signed-off-by: Jonas Kramer <jkramer@nex.scrapping.cc>
be1 (author)
Sun Sep 21 17:22:09 -0700 2008
jkramer (committer)
Mon Sep 22 07:23:17 -0700 2008
commit  f7a365e9251c63305b3226b6cca6d7f37e715788
tree    c2294d9237db0f29f8772ba549523ba8c928f1dd
parent  41a0adb8091f9718a5c9ac081d56c28b769b6791
...
210
211
212
 
213
 
214
215
216
217
218
219
 
220
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
221
222
223
...
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
0
@@ -210,14 +210,34 @@ int main(int argc, char ** argv) {
0
 
0
   /* Fork to background. */
0
   if(background) {
0
+ int null;
0
     pid_t pid = fork();
0
+
0
     if(pid == -1) {
0
       fputs("Failed to daemonize.\n", stderr);
0
       exit(EXIT_FAILURE);
0
     } else if(pid) {
0
       exit(EXIT_SUCCESS);
0
     }
0
+
0
     enable(QUIET);
0
+
0
+ /* Detach from TTY */
0
+ setsid();
0
+ pid = fork();
0
+
0
+ if(pid > 0)
0
+ exit(EXIT_SUCCESS);
0
+
0
+ /* Close stdin out and err */
0
+ close(0);
0
+ close(1);
0
+ close(2);
0
+
0
+ /* Redirect stdin and out to /dev/null */
0
+ null = open("/dev/null", O_RDWR);
0
+ dup(null);
0
+ dup(null);
0
   }
0
   
0
   ppid = getpid();
...
58
59
60
61
 
62
63
64
...
319
320
321
322
 
323
324
325
...
58
59
60
 
61
62
63
64
...
319
320
321
 
322
323
324
325
0
@@ -58,7 +58,7 @@ struct stream {
0
 
0
 static enum mad_flow input(void *, struct mad_stream *);
0
 static enum mad_flow output(void *, const struct mad_header *, struct mad_pcm *);
0
-static signed scale(mad_fixed_t);
0
+inline signed scale(mad_fixed_t);
0
 
0
 int killed = 0;
0
 
0
@@ -319,7 +319,7 @@ static enum mad_flow output(
0
 }
0
 #endif
0
 
0
-static signed scale(register mad_fixed_t sample) {
0
+inline signed scale(register mad_fixed_t sample) {
0
   sample += (1L << (MAD_F_FRACBITS - 16));
0
   
0
   if(sample >= MAD_F_ONE)

Comments

    No one has commented yet.