Bug 251619 - sysutils/battmond: battmond dies after first suspend
Summary: sysutils/battmond: battmond dies after first suspend
Status: Closed FIXED
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: Any Any
: --- Affects Some People
Assignee: Alexandre C. Guimarães
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2020-12-05 20:52 UTC by dirtystickyfloor
Modified: 2021-04-11 13:15 UTC (History)
2 users (show)

See Also:
dirtystickyfloor: maintainer-feedback-


Attachments
proposed patch (411 bytes, text/plain)
2020-12-05 20:52 UTC, dirtystickyfloor
no flags Details
proposed patch (402 bytes, patch)
2020-12-05 21:57 UTC, dirtystickyfloor
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description dirtystickyfloor 2020-12-05 20:52:38 UTC
Created attachment 220293 [details]
proposed patch

I configured battmond to suspend instead of shutting down the system. In line 197 exec is used to invoke suspend:

execl("/usr/sbin/acpiconf", "acpiconf", "-s3", NULL);

As exec will replace the current process image with the new process, battmond is no longer running when the system resumes after battmond suspended for the first time.

To make sure that battmond is running after resume, I see two possible solutions:

1.) Replace exec with system
or
2.) Restart battmond on resume using rc-scripts

I attached a patch for solution #1
Comment 1 dirtystickyfloor 2020-12-05 21:29:51 UTC
Comment on attachment 220293 [details]
proposed patch

>--- battmond.c.orig	2020-12-05 20:19:13 UTC
>+++ battmond.c
>@@ -194,8 +194,7 @@ int main(int argc, char ** argv)
> 				if (dosuspend) { // Suspend
> 					syslog(LOG_EMERG, BATT_SUSP);
> 					close(acpifd);
>-					execl("/usr/sbin/acpiconf", "acpiconf", "-s3", NULL);
>-					oops("execl");
>+					system("/usr/sbin/acpiconf -s3");
> 				} else { // Halt
> 					syslog(LOG_EMERG, BATT_HALT);
> 					close(acpifd);
Comment 2 dirtystickyfloor 2020-12-05 21:57:08 UTC
Created attachment 220296 [details]
proposed patch
Comment 3 commit-hook freebsd_committer 2021-04-11 13:14:28 UTC
A commit in branch main references this bug:

URL: https://cgit.FreeBSD.org/ports/commit/?id=b64f1988e365b12baed8efb0e99a07299f8741e2

commit b64f1988e365b12baed8efb0e99a07299f8741e2
Author:     Alexandre C. Guimarães <rigoletto@FreeBSD.org>
AuthorDate: 2021-04-11 13:08:15 +0000
Commit:     Alexandre C. Guimarães <rigoletto@FreeBSD.org>
CommitDate: 2021-04-11 13:08:15 +0000

    sysutils/battmond: Fix battmond dies after first suspend

    - Fix won't acting if battery level suddenly drops to zero
    PR:             251618 251619
    Submitted by:   dirtystickyfloor@web.de
    Approved by:    ntarmos@gmail.com (maintainer timeout, 127 days)

 sysutils/battmond/files/patch-battmond.c (new) | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)
Comment 4 Alexandre C. Guimarães freebsd_committer 2021-04-11 13:15:20 UTC
Committed. Thanks. :-)