Package: sysrqd
Version: 5-1
Severity: normal
Tags: patch

sysrqd.c only writes the first 4 digits of the pid into
/var/run/sysrqd.pid.  pids on my system are currently around 22500...
The attached patch corrects that and even simplifies code.

-- System Information:
Debian Release: testing/unstable
  APT prefers unstable
  APT policy: (500, 'unstable'), (1, 'experimental')
Architecture: i386 (i686)
Shell:  /bin/sh linked to /bin/bash
Kernel: Linux 2.6.16.14
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8)

Versions of packages sysrqd depends on:
ii  libc6                         2.3.6-7    GNU C Library: Shared libraries

sysrqd recommends no packages.

-- no debconf information
--- sysrqd.c-orig	2006-05-01 02:58:25.000000000 -0700
+++ sysrqd.c	2006-05-16 04:23:55.000000000 -0700
@@ -194,17 +194,12 @@
 int
 write_pidfile(pid_t pid)
 {
-  int pidfile;
-  char pidstr[5];
-  
-  if(!(pidfile = open (PID_FILE, O_WRONLY|O_TRUNC|O_CREAT, 0644)))
+  FILE *pidf = fopen(PID_FILE, "w");
+  if (pidf == NULL)
     return 1;
-  
-  snprintf(pidstr, 5, "%d", pid);
-  
-  write (pidfile, pidstr, sizeof (pidstr));
 
-  close(pidfile);
+  fprintf(pidf, "%d\n", pid);
+  fclose(pidf);
   
   return 0;
 }

Reply via email to