MCPcopy
hub / github.com/wavetermdev/waveterm / BadgeWatchPidCommand

Method BadgeWatchPidCommand

pkg/wshrpc/wshremote/wshremote.go:141–175  ·  view source on GitHub ↗
(ctx context.Context, data wshrpc.CommandBadgeWatchPidData)

Source from the content-addressed store, hash-verified

139}
140
141func (impl *ServerImpl) BadgeWatchPidCommand(ctx context.Context, data wshrpc.CommandBadgeWatchPidData) error {
142 if data.Pid <= 0 {
143 return fmt.Errorf("invalid pid: %d", data.Pid)
144 }
145 if data.ORef.IsEmpty() {
146 return fmt.Errorf("oref is required")
147 }
148 if data.BadgeId == "" {
149 return fmt.Errorf("badgeid is required")
150 }
151 go func() {
152 defer func() {
153 panichandler.PanicHandler("BadgeWatchPidCommand", recover())
154 }()
155 for {
156 time.Sleep(time.Second)
157 if unixutil.IsPidRunning(data.Pid) {
158 continue
159 }
160 orefStr := data.ORef.String()
161 event := wps.WaveEvent{
162 Event: wps.Event_Badge,
163 Scopes: []string{orefStr},
164 Data: baseds.BadgeEvent{
165 ORef: orefStr,
166 ClearById: data.BadgeId,
167 },
168 }
169 wshclient.EventPublishCommand(impl.RpcClient, event, nil)
170 log.Printf("BadgeWatchPidCommand: pid %d gone, cleared badge %s for oref %s\n", data.Pid, data.BadgeId, orefStr)
171 return
172 }
173 }()
174 return nil
175}

Callers

nothing calls this directly

Calls 5

PanicHandlerFunction · 0.92
IsPidRunningFunction · 0.92
EventPublishCommandFunction · 0.92
IsEmptyMethod · 0.45
StringMethod · 0.45

Tested by

no test coverage detected