All pastes #38661 Raw Edit

Rewrite of sharp 2.4 kernels APM workaround to C.

public c v1 · immutable
#38661 ·published 2006-01-26 14:18 UTC
rendered paste body
Rewrite of sharp 2.4 kernels APM workaround to C.Shell version:---------------------------------------------------------------#!/bin/shif ( cat /proc/cpuinfo|grep -i hardware|grep -i SHARP ) && \   [ ".$@" = ".-s" -o ".$@" = ".--suspend" ]; then	killall -USR1 apmd || /usr/bin/apm.orig -selse	/usr/bin/apm.orig "$@"fi---------------------------------------------------------------C version:---------------------------------------------------------------Index: apmd-3.2.2.orig/apm.c===================================================================--- apmd-3.2.2.orig.orig/apm.c	2006-01-26 15:15:27.000000000 +0100+++ apmd-3.2.2.orig/apm.c	2006-01-26 15:15:36.000000000 +0100@@ -28,6 +28,7 @@ #include <errno.h> #include <time.h> #include <getopt.h>+#include <signal.h> #include "apm.h"  static int verbose = 0;@@ -43,6 +44,8 @@     int fd;     time_t then, now;     int error;+    FILE* pid_file;+    int apmd_pid;      fd = open(APM_DEVICE, O_WRONLY);     if (fd < 0)@@ -54,6 +57,16 @@     switch (mode)     {     case SUSPEND:+	if( 0 == system("grep -i hardware /proc/cpuinfo|grep -i SHARP"))+	{+	    pid_file = fopen("/var/run/apmd.pid", "r");+	    if(pid_file)+	    {+		fscanf(pid_file, "%d", &apmd_pid);+	    }++	    kill(apmd_pid, SIGKILL);+	} 	error = apm_suspend(fd); 	break;     case STANDBY: