summaryrefslogtreecommitdiff
path: root/libopie
authorsandman <sandman>2002-11-20 22:50:41 (UTC)
committer sandman <sandman>2002-11-20 22:50:41 (UTC)
commit9cef034e112118ad388b0678cd492d81b1695021 (patch) (unidiff)
treeac3da27c6ccc31663583a2f223098765f5d2d4a3 /libopie
parent15c598ff6bc390ca0d2b0c82b236b4dd3257bb99 (diff)
downloadopie-9cef034e112118ad388b0678cd492d81b1695021.zip
opie-9cef034e112118ad388b0678cd492d81b1695021.tar.gz
opie-9cef034e112118ad388b0678cd492d81b1695021.tar.bz2
Reverting back to use system ( "apm --suspend" );, even though I don't
like it. It is needed since a real apm implementation only allows suspends by uid == 0, which doesn't work with a multi-user Opie. So making apm SUID root and calling it on suspend is the only option here.
Diffstat (limited to 'libopie') (more/less context) (show whitespace changes)
-rw-r--r--libopie/odevice.cpp18
1 files changed, 4 insertions, 14 deletions
diff --git a/libopie/odevice.cpp b/libopie/odevice.cpp
index 2d2f7db..d8415ad 100644
--- a/libopie/odevice.cpp
+++ b/libopie/odevice.cpp
@@ -199,33 +199,23 @@ bool ODevice::suspend ( )
199 if ( d-> m_model == Model_Unknown ) // better don't suspend in qvfb / on unkown devices 199 if ( d-> m_model == Model_Unknown ) // better don't suspend in qvfb / on unkown devices
200 return false; 200 return false;
201 201
202 int fd;
203 bool res = false; 202 bool res = false;
204 203
205 if ((( fd = ::open ( "/dev/apm_bios", O_RDWR )) >= 0 ) ||
206 (( fd = ::open ( "/dev/misc/apm_bios",O_RDWR )) >= 0 )) {
207 struct timeval tvs, tvn; 204 struct timeval tvs, tvn;
208
209 // ::signal ( SIGTSTP, SIG_IGN );// we don't want to be stopped
210 ::gettimeofday ( &tvs, 0 ); 205 ::gettimeofday ( &tvs, 0 );
211 206
212 ::sync ( ); // flush fs caches 207 ::sync ( ); // flush fs caches
208 res = ( ::system ( "apm --suspend" ) == 0 );
213 209
214 res = ( ::ioctl ( fd, APM_IOC_SUSPEND, 0 ) == 0 ); // tell the kernel to "start" suspending 210 // This is needed because the iPAQ apm implementation is asynchronous and we
215 ::close ( fd ); 211 // can not be sure when exactly the device is really suspended
212 // This can be deleted as soon as a stable familiar with a synchronous apm implementation exists.
216 213
217 if ( res ) { 214 if ( res ) {
218 // ::kill ( -::getpid ( ), SIGTSTP ); // stop everthing in our process group
219
220 do { // wait at most 1.5 sec: either suspend didn't work or the device resumed 215 do { // wait at most 1.5 sec: either suspend didn't work or the device resumed
221 ::usleep ( 200 * 1000 ); 216 ::usleep ( 200 * 1000 );
222 ::gettimeofday ( &tvn, 0 ); 217 ::gettimeofday ( &tvn, 0 );
223 } while ((( tvn. tv_sec - tvs. tv_sec ) * 1000 + ( tvn. tv_usec - tvs. tv_usec ) / 1000 ) < 1500 ); 218 } while ((( tvn. tv_sec - tvs. tv_sec ) * 1000 + ( tvn. tv_usec - tvs. tv_usec ) / 1000 ) < 1500 );
224
225 // ::kill ( -::getpid ( ), SIGCONT ); // continue everything in our process group
226 }
227
228 // ::signal ( SIGTSTP, SIG_DFL );
229 } 219 }
230 220
231 return res; 221 return res;