Hi,
I have made some progress on the origin of the segmentation fault when
using XmTextFieldSetString $TEXT0 "string" in a dtksh script.
Running the script with LANG=C does not produce a segfault, but with the
locale LANG=fr_FR.UTF-8
dtksh segfaults. It looks like a problem with dtksh handling of strings
in XmTextFieldSetString in (some ?)
UTF-8 locales since I haven't seen the same problem with xmaddressbook
that also uses XmTextSetString. A simple workaround is to add LANG=C
just after #!/usr/dt/bin/dtksh.
Le 11/03/2025 à 10:36, Bernd Blümmel a écrit :
Hi,
no segmentation fault at fedora asahi remix f41
(Apple MacBook Pro (14-inch, M2 Pro, 2023))
uname -a:
Linux babbasFedora 6.13.5-400.asahi.fc41.aarch64+16k #1 SMP
PREEMPT_DYNAMIC Sat Mar 8 15:
03:17 UTC 2025 aarch64 GNU/Linux
CDE Version is 2.5.2
(device files modified)
The method to modify XmTextField seems to be correct.
Am 10.03.25 um 19:39 schrieb Edmond Orignac via cdesktopenv-devel:
I am unsure if this is a bug in dtksh or if I am using an illegal
instruction.
The program below terminates with a segmentation fault error when I
try to use it.
The segmentation fault arises when the script executes the
instructions XmTextFieldSetString.
changing editable:false to editable:true in XmCreateTextField does
not change anything.
I have also tried to replace XmTextFieldSetString with
XmTextFieldGetLastPosition /XmTextFieldReplace, but the segmentation
fault remains.
I am not sure if this is a bug in dtksh or if I am using an incorrect
method to modify the value of the TextField widget that only worked
because of a bug in dtksh.
I remember the program has worked on Ubuntu 20.04 LTS and older
version of CDE,
but my current system is Linux Ubuntu 22.04 LTS with CDE 2.5.2.
#!/usr/dt/bin/dtksh
# (c) Edmond Orignac, 2025
# released under MIT license
# displays battery level on Linux >=4.x in the Common Desktop
Environment
batcheck() {
read btype </sys/class/power_supply/BAT0/technology
read charge < /sys/class/power_supply/BAT0/charge_now
charge=$(($charge/1000))
read voltage < /sys/class/power_supply/BAT0/voltage_now
voltage=$(($voltage*1,0e-6))
read current < /sys/class/power_supply/BAT0/current_now
current=$(($current/1000))
read capacity < /sys/class/power_supply/BAT0/capacity
read etat < /sys/class/power_supply/BAT0/status
read adapter < /sys/class/power_supply/AC/online
if [ $current -gt 0 ]; then time=$((charge/current))
else
time='Unknown'
fi
XmTextFieldSetString $TEXT0 $btype
XmTextFieldSetString $TEXT1 $charge
XmTextFieldSetString $TEXT3 $voltage
XmTextFieldSetString $TEXT2 $capacity
XmTextFieldSetString $TEXT4 $etat
XmTextFieldSetString $TEXT5 $time
XmTextFieldSetString $TEXT6 $adapter
# We will use the current to find
# the remaining time while on battery/charging.
# We use XtAddTimeOut to call batcheck again in 10s
XtAddTimeOut BATTERY 10000 "batcheck;"
}
XtInitialize TOPLEVEL text TExt "$0" "$@"
XtCreateManagedWidget FORM form XmForm $TOPLEVEL \
marginHeight:15 \
marginWidth:15
# We don't have an exit button, since it is better that the
# program remains active during the whole session.
# We create a 2 column Row/Column Widget
XmCreateRowColumn RW0 $FORM rw0 numColumns:2 packing:PACK_COLUMN
# We start the loop to check the battery
# We fill the left column with the labels
XmCreateLabel LABEL0 $RW0 "label0" labelString:"Battery type:"
XmCreateLabel LABEL1 $RW0 "label1" labelString:"Charge Now (mAh):"
XmCreateLabel LABEL2 $RW0 "label2" labelString:"Capacity (%):"
XmCreateLabel LABEL3 $RW0 "label3" labelString:"Voltage (V):"
XmCreateLabel LABEL4 $RW0 "label4" labelString:"State:"
XmCreateLabel LABEL5 $RW0 "label5" labelString:"Time Remaining (h)"
XmCreateLabel LABEL6 $RW0 "label6" labelString:"AC-Adapter:"
btype='Unknown'
charge='50'
capacity='Unknown'
voltage='Unknown'
etat='Unknown'
adapter='Unknown'
time='Unknown'
#Now we fill right column with values
XmCreateTextField TEXT0 $RW0 "text0" editable:false value:$btype
XmCreateTextField TEXT1 $RW0 "text1" editable:false value:$charge
XmCreateTextField TEXT2 $RW0 "text2" editable:false value:$capacity
XmCreateTextField TEXT3 $RW0 "text3" editable:false value:$voltage
XmCreateTextField TEXT4 $RW0 "text4" editable:false value:$etat
XmCreateTextField TEXT5 $RW0 "text5" editable:false value:$time
XmCreateTextField TEXT6 $RW0 "text6" editable:false value:$adapter
# Mandatory if we don't use XtCreateManagedWidget to make window visible
XtManageChild $RW0
# Make the labels visible
XtManageChild $LABEL0
XtManageChild $LABEL1
XtManageChild $LABEL2
XtManageChild $LABEL3
XtManageChild $LABEL4
XtManageChild $LABEL5
XtManageChild $LABEL6
# Make the data visible
XtManageChild $TEXT0
XtManageChild $TEXT1
XtManageChild $TEXT2
XtManageChild $TEXT3
XtManageChild $TEXT4
XtManageChild $TEXT5
XtManageChild $TEXT6
batcheck;
# Enter the Xt loop
XtRealizeWidget $TOPLEVEL
XtMainLoop
_______________________________________________
cdesktopenv-devel mailing list
cdesktopenv-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/cdesktopenv-devel
--
Bernd Blümmel
Limesstraße 10
64625 Bensheim
Mail:bernd.bluem...@t-online.de
Mobil: +49 175 5709712
_______________________________________________
cdesktopenv-devel mailing list
cdesktopenv-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/cdesktopenv-devel